以下是我的自定义帖子类型和类别:
//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
)
);
}
即使已打开“show\\u in\\u nav\\u menus”(在导航菜单中显示),它仍然不会显示。我的代码有问题吗?
否则看起来效果不错。谢谢