Custom Taxonomy Not Showing in Menu

Using WordPress 3.7.1 and PHP 5.4.12 I am trying to create a Custom Post Type called “News” and an associated Taxonomy Called “Subject”. I generate the code from Generate WP site as below: After running the code I figure out that the Taxonomy is not showing in the Menu!

enter image description here

Read More

after struggling with code Little bit I updated the code Hook action by removing the “0” parameter as:

enter image description here

to:

enter image description here

Surprisingly , this time it worked! and the Subject Taxonomy appears in the Menu

enter image description here

BUT I can not add any Terms to the taxonomy as I am encountering with this red box error

enter image description here

Can you please let me know what I am doing wrong here?

<?php
// Register Custom Post Type
function custom_post_type_news() {
$labels = array(
    'name'                => 'News',
    'singular_name'       => 'news',
    'menu_name'           => 'News',
    'parent_item_colon'   => 'Parent News:',
    'all_items'           => 'All News',
    'view_item'           => 'View News',
    'add_new_item'        => 'Add New News',
    'add_new'             => 'Add New News',
    'edit_item'           => 'Edit News',
    'update_item'         => 'Update News',
    'search_items'        => 'Search News',
    'not_found'           => 'No News Found',
    'not_found_in_trash'  => 'No News Found in Trash',
);
$args = array(
    'label'               => 'news',
    'description'         => 'News Information Pages',
    'labels'              => $labels,
    'supports'            => array( 'title', 'editor', ),
    'taxonomies'          => array( 'subject' ),
    'hierarchical'        => false,
    'public'              => true,
    'show_ui'             => true,
    'show_in_menu'        => true,
    'show_in_nav_menus'   => true,
    'show_in_admin_bar'   => true,
    'menu_position'       => 5,
    'menu_icon'           => '',
    'can_export'          => true,
    'has_archive'         => true,
    'exclude_from_search' => false,
    'publicly_queryable'  => true,
    'capability_type'     => 'post',
);
register_post_type( 'news', $args );

}

// Hook into the 'init' action
add_action( 'init', 'custom_post_type_news',0);

// Register Custom Taxonomy
function custom_taxonomy_subject()  {

$labels = array(
    'name'                       => 'Subjects',
    'singular_name'              => 'Subject',
    'menu_name'                  => 'Subject',
    'all_items'                  => 'All Subjects',
    'parent_item'                => 'Parent Subject',
    'parent_item_colon'          => 'Parent Subject:',
    'new_item_name'              => 'New Subject Name',
    'add_new_item'               => 'Add New Subject',
    'edit_item'                  => 'Edit Subject',
    'update_item'                => 'Update Subject',
    'separate_items_with_commas' => 'Separate Subject with commas',
    'search_items'               => 'Search Subjects',
    'add_or_remove_items'        => 'Add or remove Subjects',
    'choose_from_most_used'      => 'Choose from the most used Subjects',
);
$args = array(
    'labels'                     => $labels,
    'hierarchical'               => true,
    'public'                     => true,
    'show_ui'                    => true,
    'show_admin_column'          => true,
    'show_in_nav_menus'          => true,
    'show_tagcloud'              => true,
);
register_taxonomy( 'subject', 'news', $args );

}
// Hook into the 'init' action
add_action( 'init', 'custom_taxonomy_subject', 0 );

Related posts

1 comment

  1. As seen in the Codex: http://codex.wordpress.org/Function_Reference/register_taxonomy

    <?php
    add_action( 'init', 'create_book_tax' );
    
    function create_book_tax() {
        register_taxonomy(
            'genre',
            'book',
            array(
                'label' => __( 'Genre' ),
                'rewrite' => array( 'slug' => 'genre' ),
                'hierarchical' => true,
            )
        );
    }
    ?>
    

    From what I see in your code, you are not linking the taxonomy to your post-type. Try changing

    custom_post_type
    

    to

    news
    

Comments are closed.