【发布时间】:2021-03-05 17:52:42
【问题描述】:
我的 wordpress 网站中有 2 种自定义帖子类型,
// Our custom post type function
function create_posttype() {
register_post_type( 'properties',
// CPT Options
array(
'labels' => array(
'name' => __( 'Properties' ),
'singular_name' => __( 'Property' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'properties'),
'show_in_rest' => true,
)
);
}
// Hooking up our function to theme setup
add_action( 'init', 'create_posttype' );
和
// Our custom post type function
function create_team_posttype() {
register_post_type( 'team',
// CPT Options
array(
'labels' => array(
'name' => __( 'Team Members' ),
'singular_name' => __( 'Team Member' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'our-team'),
'show_in_rest' => true,
)
);
}
// Hooking up our function to theme setup
add_action( 'init', 'create_team_posttype' );
当我转到mydomain.com/properties 时,我看到了我的archive-properties.php 页面模板,我看到了正确的模板和内容。我有一个名为archive-team.php 的团队存档teamplate,但是当我转到它的URl mydomain.com/our-team 我看到archive-properties.php 模板我做错了什么吗?
【问题讨论】:
标签: php wordpress custom-post-type