我有x个自定义帖子类型。所有这些自定义的帖子类型都在网站的各个地方得到了响应;即,它们被查询和检索而没有任何问题。尽管如此,我还是为一些自定义帖子类型提供了一个页面模板。突然之间,这些page-templates
不再用于页面本身。例如,我有一个"团队"类型。WP页面被正确地指定为使用团队模板和所有相关的东西,但它并没有实际使用模板,而是只使用index.php
。我可能已经刷新了几百次永久链接。我也尝试过制作page-{post-type}
页面和page.php
模板,但它也跳过了这些。尽管如此,single-{post-type}
模板仍然可以工作。
我甚至尝试将我的数据库恢复到错误开始之前的时间,但最终错误会再次出现并持续存在。我没主意了。
**此外,这些页面将使用默认的永久链接,但不是漂亮的永久链接(是的,我已经检查了.htaccess
)。
$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);
模板名称为:team.php
。我确信这些都不是问题,因为我在许多网站上使用过自定义帖子类型,从未遇到过这样的问题。
更新:我重新安装了WP,并完全重新填充了一个新数据库,但仍然收到同样的错误,所以这一定与我的代码有关,但到目前为止,我真的不知道从哪里开始。
这是我自己想出来的。最终,页面名称与帖子类型相冲突,因为我有一个名为/team的页面,但也有一个名称为team的帖子类型,因此/team/team成员的结构与just/team相冲突,这也解释了为什么单-{帖子类型}仍然有效。