我有x个自定义帖子类型。所有这些自定义帖子类型都在网站上的不同地方得到了响应;也就是说,它们被查询和检索时没有任何问题。尽管如此,我还是有一个页面模板来支持一些自定义的帖子类型。突然之间,这些page-templates不再用于页面本身。例如,我有一个“团队”类型。WP页面被正确地指定为使用团队模板和所有相关内容,但实际上并没有使用模板,它只使用了index.php。我可能已经刷新了永久链接几百次了。我还尝试过制作page-{post-type}页面和page.php模板,但它也跳过了这些步骤。尽管如此,single-{post-type}模板仍然可以工作。
我甚至尝试将我的数据库恢复到bug开始之前的某个时间,但最终bug会再次出现并持续存在。我没主意了。
**此外,页面可以使用默认的固定链接,但不是很好的固定链接(是的,我已经检查了.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,并完全重新填充了一个新的数据库,但仍然收到相同的错误,所以它一定与我的代码有关,但到目前为止,我真的不知道从哪里开始。
发布于 2014-09-30 03:01:25
我自己想出来的。它最终导致页面名称与post类型冲突,因为我有一个名为/team的页面,但还有一个名为team的post类型,因此将/team /team -member的结构与/team冲突,这也解释了为什么single-{ post-type }仍然有效。
https://stackoverflow.com/questions/26104906
复制相似问题