我将自定义帖子类型添加到名为Projects的主题中。它使用内置的类别分类法,但无法获得前端列出的那些项目类别帖子。
以下是我用于创建自定义帖子类型的代码
// Register Custom Post Type
function custom_post_type(){
$labels = array(
'name' => 'Projects',
'singular_name' => 'Project',
'menu_name' => 'Projects',
'parent_item_colon' => 'Parent Item:',
'all_items' => 'All Items',
'view_item' => 'View Item',
'add_new_item' => 'Add New Item',
'add_new' => 'Add New',
'edit_item' => 'Edit Item',
'update_item' => 'Update Item',
'search_items' => 'Search Item',
'not_found' => 'Not found',
'not_found_in_trash' => 'Not found in Trash',
);
$args = array(
'label' => 'projects',
'description' => 'Project Description',
'labels' => $labels,
'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', ),
'taxonomies' => array( 'category', 'post_tag' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
);
register_post_type( 'projects', $args );
感谢任何帮助