【发布时间】:2018-10-09 13:14:16
【问题描述】:
我在 WordPress 中设置了自定义帖子类型(下面的代码),并在我的主题中设置了 archive-team.php,但是当我访问 example.com/meet-the-team/ 时,它没有使用应有的存档模板做。
它以前工作但不再工作,它只是使用 page.php 模板。
function cptui_register_my_cpts_team() {
/**
* Post Type: Team Members.
*/
$labels = array(
"name" => __( "Team Members", "" ),
"singular_name" => __( "Team Member", "" ),
);
$args = array(
"label" => __( "Team Members", "" ),
"labels" => $labels,
"description" => "",
"public" => true,
"publicly_queryable" => true,
"show_ui" => true,
"show_in_rest" => false,
"rest_base" => "",
"has_archive" => "meet-the-team",
"show_in_menu" => true,
"show_in_nav_menus" => true,
"exclude_from_search" => false,
"capability_type" => "post",
"map_meta_cap" => true,
"hierarchical" => false,
"rewrite" => array( "slug" => "team", "with_front" => true ),
"query_var" => true,
"menu_icon" => "dashicons-groups",
"supports" => array( "title", "page-attributes" ),
);
register_post_type( "team", $args );
}
add_action( 'init', 'cptui_register_my_cpts_team' );
我已经刷新了永久链接并尝试再次添加 CPT,但没有任何乐趣。
【问题讨论】:
-
您实际使用的是什么文件名? archive-team.php 还是 archive-meet-the-team.php?
-
存档-team.php
标签: wordpress custom-post-type