0

I have defined a few custom taxonomies in my functions.php using the following code:

<?php
add_action( 'init', function() {
    $labels = array(
        'name'              => _x( 'Resource Centers', 'taxonomy general name', 'textdomain' ),
        'singular_name'     => _x( 'Resource Center', 'taxonomy singular name', 'textdomain' ),
        'search_items'      => __( 'Search Resource Centers', 'textdomain' ),
        'all_items'         => __( 'All Resource Centers', 'textdomain' ),
        'parent_item'       => __( 'Parent Resource Center', 'textdomain' ),
        'parent_item_colon' => __( 'Parent Resource Center:', 'textdomain' ),
        'edit_item'         => __( 'Edit Resource Center', 'textdomain' ),
        'update_item'       => __( 'Update Resource Center', 'textdomain' ),
        'add_new_item'      => __( 'Add New Resource Center', 'textdomain' ),
        'new_item_name'     => __( 'New Resource Center Name', 'textdomain' ),
        'menu_name'         => __( 'Resource Center', 'textdomain' ),
    );
    $args = array(
        'hierarchical'      => true,
        'labels'            => $labels,
        'show_ui'           => true,
        'show_in_menu'      => true,
        'public'            => true,
        'show_admin_column' => true,
        'query_var'         => true,
        'rewrite'           => array( 'slug' => 'resource-center' ),
    );
    register_taxonomy( 'resource-center', array( 'post' ), $args );
    $labels = array(
        'name'              => _x( 'Blog Categories', 'taxonomy general name', 'textdomain' ),
        'singular_name'     => _x( 'Blog', 'taxonomy singular name', 'textdomain' ),
        'search_items'      => __( 'Search Blog Categories', 'textdomain' ),
        'all_items'         => __( 'All Blog Categories', 'textdomain' ),
        'parent_item'       => __( 'Parent Blog Category', 'textdomain' ),
        'parent_item_colon' => __( 'Parent Blog Category:', 'textdomain' ),
        'edit_item'         => __( 'Edit Blog Category', 'textdomain' ),
        'update_item'       => __( 'Update Blog Category', 'textdomain' ),
        'add_new_item'      => __( 'Add New Blog Category', 'textdomain' ),
        'new_item_name'     => __( 'New Blog Category Name', 'textdomain' ),
        'menu_name'         => __( 'Blog Categories', 'textdomain' ),
    );
    $args = array(
        'hierarchical'      => true,
        'labels'            => $labels,
        'show_ui'           => true,
        'show_in_menu'      => true,
        'public'            => true,
        'show_admin_column' => true,
        'query_var'         => true,
        'rewrite'           => array( 'slug' => 'blogs', 'with_front' => true ),
    );
    register_taxonomy( 'blog', array( 'post' ), $args );
    $labels = array(
        'name'              => _x( 'Marketing Tags', 'taxonomy general name', 'textdomain' ),
        'singular_name'     => _x( 'Marketing Tag', 'taxonomy singular name', 'textdomain' ),
        'search_items'      => __( 'Search Marketing Tags', 'textdomain' ),
        'all_items'         => __( 'All Marketing Tags', 'textdomain' ),
        'parent_item'       => __( 'Parent Marketing Tag', 'textdomain' ),
        'parent_item_colon' => __( 'Parent Marketing Tag:', 'textdomain' ),
        'edit_item'         => __( 'Edit Marketing Tag', 'textdomain' ),
        'update_item'       => __( 'Update Marketing Tag', 'textdomain' ),
        'add_new_item'      => __( 'Add New Marketing Tag', 'textdomain' ),
        'new_item_name'     => __( 'New Marketing Tag Name', 'textdomain' ),
        'menu_name'         => __( 'Marketing Tag', 'textdomain' ),
    );
    $args = array(
        'hierarchical'      => false,
        'labels'            => $labels,
        'show_ui'           => true,
        'show_in_menu'      => true,
        'public'            => true,
        'show_admin_column' => true,
        'query_var'         => true,
        'rewrite'           => array( 'slug' => 'marketing-tag' ),
    );
    register_taxonomy( 'marketing-tag', array( 'post' ), $args );
    $labels = array(
        'name'              => _x( 'Video Playlists', 'taxonomy general name', 'textdomain' ),
        'singular_name'     => _x( 'Video Playlist', 'taxonomy singular name', 'textdomain' ),
        'search_items'      => __( 'Search Video Playlists', 'textdomain' ),
        'all_items'         => __( 'All Video Playlists', 'textdomain' ),
        'parent_item'       => __( 'Parent Video Playlist', 'textdomain' ),
        'parent_item_colon' => __( 'Parent Video Playlist:', 'textdomain' ),
        'edit_item'         => __( 'Edit Video Playlist', 'textdomain' ),
        'update_item'       => __( 'Update Video Playlist', 'textdomain' ),
        'add_new_item'      => __( 'Add New Video Playlist', 'textdomain' ),
        'new_item_name'     => __( 'New Video Playlist Name', 'textdomain' ),
        'menu_name'         => __( 'Video Playlist', 'textdomain' ),
    );
    $args = array(
        'hierarchical'      => true,
        'labels'            => $labels,
        'show_ui'           => true,
        'show_in_menu'      => true,
        'public'            => true,
        'show_admin_column' => true,
        'query_var'         => true,
        'rewrite'           => array( 'slug' => 'video-playlist' ),
    );
    register_taxonomy( 'video-playlist', array( 'post' ), $args );
    flush_rewrite_rules(true);
});

As far as I can tell, they are all created correctly and are set to public and visible in the menu/ui. They all work correctly when editing a post, or when accessed directly via the admin URL, e.g.:

/wp-admin/edit-tags.php?taxonomy=blog
/wp-admin/edit-tags.php?taxonomy=marketing-tag
/wp-admin/edit-tags.php?taxonomy=video-playlist

However, only the Resource Centers taxonomy shows up in the admin menu under posts. The others are missing:

admin menu

Any idea why some of my custom taxonomies don't show in the menu? As silly as it sounds, they used to show up and somehow they just vanished.

  • You probably should post the code where you're defining your custom taxonomy. – Cedon Apr 7 '17 at 15:21
  • I did, right in the question (link to the gist). – Jon Apr 7 '17 at 15:26
  • LOL. Totally missed that link. Looking at the code, you're not using a priority. In the WordPress documentation, they have the call using a priority of 0. Also, have you tried creating a defined function and then calling it with add_action()? – Cedon Apr 7 '17 at 16:03
  • I used to have it running with a priority of 0 but removed that as part of my debugging--it did not make a difference. – Jon Apr 7 '17 at 16:09
  • I am also calling this inside of an add_action wrapper/function (see line 2 of the gist) – Jon Apr 7 '17 at 16:09
1

Turns out this was caused by a plugin--I turned off all plugins and enabled them one at a time. Eventually one made the custom taxonomies disappear again.

This is the plugin that caused the issue: https://wordpress.org/plugins/playbuzz/

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.