最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Showing custom post type categories in the menu

programmeradmin1浏览0评论

here is my custom post type and category:

//Register nav
register_nav_menus( array(
    'main_nav' => 'Main navigation'
) );

//Custom post types
add_action( 'init', 'create_post_type' );
function create_post_type() {
    register_post_type( 'assets',
        array(
            'labels' => array(
                'name' => __( 'Assets' ),
                'show_in_nav_menus' => true,
                'show_in_menu' => true,
                'singular_name' => __( 'Asset' )
            ),
        'public' => true,
        'has_archive' => true,
        )
    );
}

//Custom post type taxonomy/category
add_action( 'init', 'build_taxonomies', 0 );
function build_taxonomies() {
    register_taxonomy( 'categories', 'assets',
        array(
            'hierarchical' => true,
            'label' => 'Categories',
            'query_var' => true,
            'rewrite' => true
        )
    );
}

Even though I have 'show_in_nav_menus' turned on, it still won't show. Is there something wrong with my code?

It seems to work fine otherwise. Thanks

here is my custom post type and category:

//Register nav
register_nav_menus( array(
    'main_nav' => 'Main navigation'
) );

//Custom post types
add_action( 'init', 'create_post_type' );
function create_post_type() {
    register_post_type( 'assets',
        array(
            'labels' => array(
                'name' => __( 'Assets' ),
                'show_in_nav_menus' => true,
                'show_in_menu' => true,
                'singular_name' => __( 'Asset' )
            ),
        'public' => true,
        'has_archive' => true,
        )
    );
}

//Custom post type taxonomy/category
add_action( 'init', 'build_taxonomies', 0 );
function build_taxonomies() {
    register_taxonomy( 'categories', 'assets',
        array(
            'hierarchical' => true,
            'label' => 'Categories',
            'query_var' => true,
            'rewrite' => true
        )
    );
}

Even though I have 'show_in_nav_menus' turned on, it still won't show. Is there something wrong with my code?

It seems to work fine otherwise. Thanks

Share Improve this question asked May 6, 2013 at 23:18 PhillPhill 1971 gold badge1 silver badge10 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 2

To show your custom post types in menu items. Go to menus and select screen options on the top and make sure your custom post type checked.

Ugh. Fixed.

You have to show the 2nd category box in screen options, I could only see the default post categories. I'm glad I spent 40 mins trying new bits of code for that.

Thanks

发布评论

评论列表(0)

  1. 暂无评论