我创建一个自定义帖子类型,在主题中添加以下代码functions.php
function cptarchivePost_init() {
$args = array(
\'label\' => \'Archive Post\',
\'public\' => true,
\'show_ui\' => true,
\'capability_type\' => \'post\',
\'hierarchical\' => false,
\'rewrite\' => array(\'slug\' => \'cpt_archive_post\'),
\'query_var\' => true,
\'menu_icon\' => \'dashicons-video-alt\',
\'supports\' => array(
\'title\',
\'editor\',
\'excerpt\',
\'trackbacks\',
\'custom-fields\',
\'comments\',
\'revisions\',
\'thumbnail\',
\'author\',
\'page-attributes\',)
);
register_post_type( \'cpt_archive_post\', $args );
}
add_action( \'init\', \'cptarchivePost_init\' );
add_action( \'init\', \'create_cpt_archive_category\', 0 );
function create_cpt_archive_category() {
register_taxonomy(
\'cpt_archive_category\',
\'cpt_archive_post\',
array(
\'labels\' => array(
\'name\' => \'Category\',
\'add_new_item\' => \'Add Category\',
\'new_item_name\' => "New Category"
),
\'show_ui\' => true,
\'show_tagcloud\' => false,
\'hierarchical\' => true
)
);
}
并在主题中创建一个名为
single-cpt_archive_post.php
但仍然是使用索引的帖子。php模板
有人能帮助我如何为自定义帖子创建单个模板吗