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

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

enter image description here


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?

// 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 );
  • your code works fine as-is. disable plugins and switch to core-bundled theme, see if issue persists. – Milo Nov 15 '13 at 4:07

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

add_action( 'init', 'create_book_tax' );

function create_book_tax() {
            '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



  • Hi Bobby I updated the code as :register_taxonomy( 'subject', 'news', $args ); but still gettng same error box! – Mona Coder Nov 15 '13 at 3:03
  • add_action('init', 'custom_taxonomy_subject'); Don't forget to add the taxonomy action too. – Bobby-Joe Audet Nov 15 '13 at 3:12
  • Actually, I already have this in my code , Sorry I just forget to paste it here! by the way I undated the code – Mona Coder Nov 15 '13 at 3:46

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.