WordPress.org

Ready to get started?Download WordPress

Forums

is_taxonomy() does not recognize custom taxonomies (5 posts)

  1. ragulka
    Member
    Posted 3 years ago #

    WHen I have created a new taxonomy, then WordPress internal fuction is_taxonomy() does not recognize my taxonomy. This leads to a number of problems - for example, I cannot use wp_insert_term on wp_update_term on wp_set_post_terms

  2. Michael Fields
    Themer
    Posted 3 years ago #

    I can verify that is_taxonomy() does in fact work on custom taxonomies. The issue that you are most likely experiencing is that you are calling the function too early. The following two examples should illustrate:

    add_action( 'init', 'is_there_a_doggie_treat_taxonomy', 0 );
    add_action( 'init', 'create_doggie_treat_taxonomy', 50 );
    add_action( 'init', 'is_there_a_doggie_treat_taxonomy', 100 );
    
    function is_there_a_doggie_treat_taxonomy() {
    	print ( is_taxonomy( 'doggie-treat' ) ) ? '<p>We Have Treats!</p>' : '<p>No Treats for you!</p>';
    }
    function create_doggie_treat_taxonomy() {
    	register_taxonomy( "doggie-treat", 'post', array(
    		'hierarchical' => true,
    		'label' => 'Doggie Treats',
    		'singular' => 'Doggie Treat',
    		'update_count_callback' => $tax['update_count_callback'],
    		) );
    }

    So, we've hooked into init 3 times. First we have checked to see if our taxonomy exists at 0. Unfortunately , it does not yet exist. At 50, we create the taxonomy and when we check for it again at 100, it is there.

    I would try hooking the function a little later.

    Best,
    -Mike

  3. jaredwilli
    Member
    Posted 3 years ago #

    is_taxonomy() was deprecated, and completely removed, same goes for is_post_type()

    Now use these instead

    taxonomy_exists()
    post_type_exists()

    Here's the trac ticket:
    http://core.trac.wordpress.org/ticket/13747

  4. Miriam de Paula
    Member
    Posted 3 years ago #

    Please, somebody help me?

    I'm having the same problem, using WP 3.0.1 ...
    I have created a custom taxonomy, named "catalogo", but when I try use print_r( get_categories('taxonomy=catalogo') ) or wp_list_categories('taxonomy=catalogo') ... or when I simply try to check if taxonomy exists, I get an error "Invalid Taxonomy" ...
    taxonomy_exists('catalogo') is returning false for me... Please.. What I did wrong?

    Thanks in advance.
    Miriam de Paula
    drika.santos.sp@gmail.com

  5. Miriam de Paula
    Member
    Posted 3 years ago #

    Sorry...
    This post has been moved to a new topic where I can explain better:
    http://wordpress.org/support/topic/wordpress-doesnt-recognize-my-custom-taxonomy?replies=1#post-1630572

Topic Closed

This topic has been closed to new replies.

About this Topic