Disable custom taxonomy by name in function

Question

I need delete some custom taxonomy with function. Users creates new taxonomies, but when user create any disabled taxonomy (for example named "custom_taxonomy1") so WP remove it with function (so blacklist for specific taxonomy name).

How can I delete with something like this:

If post type "custom_post_type" – do remove taxonomy with name array "custom_taxonomy1", "custom_taxonomy2"...

or with wp_remove_object_term() function

or I find this, but how achieve it:

function wpse_296972_pre_delete_term( $term_id, $taxonomy_name ) {
    if ( $taxonomy_name === 'organization' ) {
        $objects = get_objects_in_term( $term_id, $taxonomy );

        // delete here .
    }
}
add_action( 'pre_delete_term', 'wpse_296972_pre_delete_term' );
0
heroj 2 years 2020-10-24T09:10:19-05:00 0 Answers 6 views 0

Leave an answer

Browse
Browse