Question

i am using wordpress custom post and register_taxonomy bellow is my code .


function epg_works_register() {
    $labels = array(
        'name' => __('Works'),
        'singular_name' => __('Works'),
        'add_new' => __('Add Works Item'),
        'add_new_item' => __('Add New Works Item'),
        'edit_item' => __('Edit Works Item'),
        'new_item' => __('New Works Item'),
        'view_item' => __('View Works Item'),
        'search_items' => __('Search Works Item'),
        'not_found' => __('No Works Items found'),
        'not_found_in_trash' => __('No Works Items found in Trash'),
        'parent_item_colon' => '',
        'menu_name' => __('Works')
    );
    // Set other options for Custom Post Type

    $args = array(
        'labels'              => $labels,
        // Features this CPT supports in Post Editor
        'supports'            => array( 'title', 'editor'),

        /* A hierarchical CPT is like Pages and can have
        * Parent and child items. A non-hierarchical CPT
        * is like Posts.
        */  
        'hierarchical'        => true,
        'public' => true,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'show_in_nav_menus'   => true,
        'menu_position'       => 5,
        'can_export'          => true,
        'has_archive'         => true,
        'exclude_from_search' => true,
        'publicly_queryable'  => true,
        'capability_type'     => 'post',
    );

    // Registering your Custom Post Type
    register_post_type( 'works', $args );

    register_taxonomy('works_category', 'works', array('hierarchical' => true, 'label' => 'Works Category', 'query_var' => true, 'rewrite' => array('slug' => 'works-categorys')));

    flush_rewrite_rules();
}
add_action( 'init', 'epg_works_register');

if i am changeing register_taxonomy('works_category' to register_taxonomy('something ') it's show on http://localhost/wp-admin/nav-menus.php

but if used register_taxonomy('works_category') then i can't see anything there http://localhost/wp-admin/nav-menus.php.

What's wrong ?

Thanks

Was it helpful?

Solution

The only thing that I see is the argument 'query_var'=>true, it can be set to false, but the default value is the taxonomy name, so set it to true is maybe the cause of the failure, even the codex example set it to true, I think it can be great to try

 register_taxonomy(
      'works_category', 
      'works', 
           array(
                'hierarchical' => true, 
                'label' => 'Works Category', 
                'query_var' => 'works_category', 
                'rewrite' => array('slug' => 'works-categorys')
           )
 );

Or just suppress query_var from the array ?

OTHER TIPS

The reason for this might be also that someone's 'capabilities' in register_taxonomy aren't set right. These define management privileges based on post management capabilities:

register_taxonomy('mycat', 'mycustomtype',
 array(
 //...,
 'capabilities' => array(
  'manage_terms' => 'manage_categories',
  'edit_terms' => 'manage_categories',
  'delete_terms' => 'manage_categories',
  'assign_terms' => 'edit_posts'
  )
 )
);
Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top