0

I have a Custom Post Type (Reviews) and it has two Custom Taxonomies (Genres and Authors).

When adding/editing a Review it shows the admin tools for editing the Genres (like categories) and Authors (like tags). That's good.

But when adding/editing a standard Post, the Categories tool lists both standard Categories and my Genres, all mixed together. And the Tag tool autocompletes with a mixture of standard Tags and my Authors. That's bad.

How can I stop Categories and Tags pulling in the custom taxonomies?

Here's how I define the Genres; the Tags are similar:

function pg_genres_init() {

    $labels = array(
        'name' => _x( 'Genres', 'taxonomy general name' ),
        'singular_name' => _x( 'Genre', 'taxonomy singular name' ),
        'search_items' =>  __( 'Search Genres' ),
        'all_items' => __( 'All Genres' ),
        'parent_item' => __( 'Parent Genre' ),
        'parent_item_colon' => __( 'Parent Genre:' ),
        'edit_item' => __( 'Edit Genre' ), 
        'update_item' => __( 'Update Genre' ),
        'add_new_item' => __( 'Add New Genre' ),
        'new_item_name' => __( 'New Genre Name' ),
        'menu_name' => __( 'Genres' ),
    );  

    register_taxonomy(
        'pg_genres',
        'pg_review',
        array(
            'hierarchical' => true,
            'labels' => $labels,
            'show_ui' => true,
            'show_admin_column' => true,
            'query_var' => true,
            'rewrite' => array(
                'slug' => 'reading/genre',
                'with_front' => false
            ),
        )
    );
}
add_action( 'init', 'pg_genres_init', 0 );
  • Is it possible that you registered your review post type as "pg_reviews" (plural) rather than "pg_review"? If it doesn't match up exactly that could explain why the taxonomies appear on all post types. – WebElaine Feb 20 '17 at 19:55
  • Good thinking, but unfortunately that's not the case. These custom taxonomies are showing up perfectly on the Reviews' add/edit page, which is why it seems extra confusing they're also mixed in with the Posts' categories and tags. – Phil Gyford Feb 21 '17 at 10:44
1

After looking more closely at the (default) Categories and Tags, and comparing them with the (custom) Genres and Authors I realised that although it looked like they were mixed, there were actually duplicates. e.g. the Tag 'A S Byatt' had a different ID to the Author 'A S Byatt'. And the Tag 'A S Byatt' had no Posts associated with it.

So, I held my breath and, in the WP Admin, deleted all of the Categories and Tags that had no Posts associated with them. All the Genres and Authors remained and everything now works as it should.

I guess at some point during my development, something went wrong and all the Genres and Authors were copied into the Categories and Tags taxonomies. I've no idea how that happened...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.