Wordpress跳过指定的模板-{post type},向右跳转到index.php
我有x个自定义帖子类型。所有这些定制的帖子类型在网站的各个地方都有反映;也就是说,查询和检索它们没有任何问题。尽管如此,我还是为一些自定义帖子类型提供了一个页面模板。突然,这些Wordpress跳过指定的模板-{post type},向右跳转到index.php,php,wordpress,templates,Php,Wordpress,Templates,我有x个自定义帖子类型。所有这些定制的帖子类型在网站的各个地方都有反映;也就是说,查询和检索它们没有任何问题。尽管如此,我还是为一些自定义帖子类型提供了一个页面模板。突然,这些页面模板不再用于页面本身。例如,我有一个“团队”类型。WP页面被正确地指定为使用团队模板以及所有相关的东西,但是它没有实际使用模板,而是使用index.php。我已经刷新了permalinks大概数百次了。我也尝试过制作page-{post type}页面和page.php模板,但它也跳过了这些。尽管如此,single-{
页面模板
不再用于页面本身。例如,我有一个“团队”类型。WP页面被正确地指定为使用团队模板以及所有相关的东西,但是它没有实际使用模板,而是使用index.php
。我已经刷新了permalinks大概数百次了。我也尝试过制作page-{post type}
页面和page.php
模板,但它也跳过了这些。尽管如此,single-{post-type}
模板仍然有效
我甚至尝试过将数据库恢复到bug开始之前的某个时间,但最终bug会再次弹出并持续存在。我没有主意了
**此外,这些页面将使用默认的永久链接,但不是很好的永久链接(是的,我已经检查了.htaccess
)
模板名为:team.php
。我确信这些都不是问题,因为我在许多网站上使用过自定义的帖子类型,从来没有遇到过这样的问题
更新:我重新安装了WP并完全重新填充了一个新的数据库,但仍然收到相同的错误,所以这一定与我的代码有关,但到目前为止,我真的不知道从哪里开始。我自己解决了这个问题。最终,页面名称与post类型冲突,因为我有一个名为/team的页面,但也有一个名为team的post类型,因此/team/team member的结构与just/team冲突,这也解释了为什么single-{post type}仍然有效
$labels = array(
'name' => _x('Team', 'post type general name'),
'singular_name' => _x('Team', 'post type singular name'),
'add_new' => _x('Add New', 'Team'),
'add_new_item' => __('Add New Team'),
'edit_item' => __('Edit Team'),
'new_item' => __('New Team'),
'view_item' => __('View Team'),
'search_items' => __('Search Team'),
'not_found' => __('Nothing found'),
'not_found_in_trash' => __('Nothing found in Trash'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'capability_type' => 'post',
'hierarchical' => false,
'has_archive' => true,
'menu_position' => null,
'supports' => array('title', 'editor', 'thumbnail'),
'rewrite' => true,
'show_in_nav_menus' => true,
);
register_post_type('team' , $args);