WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Custom Taxonomies: "Invalid Taxonomy" error and filtering problem (10 posts)

  1. tzeldin88
    Member
    Posted 4 years ago #

    Just in case anyone else is having the same problem I just spent the last 7 hours on, I thought I'd share this on the forum.

    I created a CUSTOM TAXONOMY in my functions.php for "Industries":

    function create_my_taxonomies() {
    	register_taxonomy(
    		'industries',
    		'post',
    		array(
    			'hierarchical' => false,
    			'label' => 'Industries',
    			'query_var' => true,
    			'rewrite' => true
    		)
    	);
    }
    add_action('init', 'create_my_taxonomies', 0);

    but two things were not working correctly:

    1) When editing a post, clicking the "Choose from the most used tags in Industries" link showed "Invalid Taxonomy".

    2) When viewing the "Industry" page that shows all the terms for that taxonomy, and the number of posts using each one.. clicking those count links goes to the list of posts (Edit Posts page) but failed to filter down to just posts with the term i had clicked. Instead it showed all posts.

    THE FIX:
    Finally i realized that, in my original code in functions.php, the Taxonomy Name (the first argument) must be all LOWERCASE! I had used initial caps ("Industries").

    That's probably obvious to most people, but I missed it. Hopefully this will help if you did too.

  2. cippoo
    Member
    Posted 3 years ago #

    Thank you very much :)

  3. JMcIntyre
    Member
    Posted 3 years ago #

    Thanks :)

  4. outlierdesign
    Member
    Posted 3 years ago #

    I LOVE YOU!!!!!!!!!!!!!!

    You have NO idea how much insanity this saved me.

  5. andy_woz
    Member
    Posted 3 years ago #

    Can I add that there should be no spaces either. Thanks, I looked high and low as to why my custom tags were bent out of shape an the popular tag cloud wasn't appearing in the admin.
    :)

    A

  6. vectyr
    Member
    Posted 3 years ago #

    You are a genius. I love you too. I am using the Custom Post Types Plugin and can confirm that the NAME needs to be in all lowercase letters, the Label can be whatever you want.

  7. toscho
    Member
    Posted 3 years ago #

    Underscores kill the tag box too.

  8. Scott
    Member
    Posted 3 years ago #

    Thank you!

  9. andyxmas
    Member
    Posted 3 years ago #

    brilliant - thankyou!

  10. glamhaus
    Member
    Posted 3 years ago #

    THANKS! I was wondering what was wrong with my listings!!

Topic Closed

This topic has been closed to new replies.

About this Topic