自定义帖子类型和404页

时间:2012-11-12 作者:Joe Bobby

我已经尝试刷新我的永久链接,但我仍然无法让它正常工作。

我有分类movies, gaming, blu-ray, 和tv 已创建,因此我的URLsite.com/movies/ 例如我想找一个电影的帖子site.com/movies/post-here/ 所以对于我的自定义帖子类型,我的头条是“电影”。

类别下所有我的普通wordpress PSOTmovies 现在正在404中,而专门从帖子类型创建的帖子Movie Posts 工作正常。这正常吗?是否有一个步骤我没有包括在内?

以下是我的所有自定义帖子类型(使用自定义帖子类型UI创建):

//Movies Custom Post Type
register_post_type(\'movies_cp\', array(  \'label\' => \'Movie Posts\',\'description\' => \'\',\'public\' => true,\'show_ui\' => true,\'show_in_menu\' => true,\'capability_type\' => \'post\',\'hierarchical\' => false,\'rewrite\' => array(\'slug\' => \'movies\'),\'query_var\' => true,\'exclude_from_search\' => false,\'supports\' => array(\'title\',\'editor\',\'excerpt\',\'trackbacks\',\'custom-fields\',\'comments\',\'revisions\',\'thumbnail\',\'author\',\'page-attributes\',),\'taxonomies\' => array(\'category\',\'post_tag\',),\'labels\' => array (
  \'name\' => \'Movie Posts\',
  \'singular_name\' => \'Movie Post\',
  \'menu_name\' => \'Movie Posts\',
  \'add_new\' => \'Add Movie Post\',
  \'add_new_item\' => \'Add New Movie Post\',
  \'edit\' => \'Edit\',
  \'edit_item\' => \'Edit Movie Post\',
  \'new_item\' => \'New Movie Post\',
  \'view\' => \'View Movie Post\',
  \'view_item\' => \'View Movie Post\',
  \'search_items\' => \'Search Movie Posts\',
  \'not_found\' => \'No Movie Posts Found\',
  \'not_found_in_trash\' => \'No Movie Posts Found in Trash\',
  \'parent\' => \'Parent Movie Post\',
),) );


//Gaming Custom Post Type
register_post_type(\'gaming_cp\', array(  \'label\' => \'Gaming Posts\',\'description\' => \'\',\'public\' => true,\'show_ui\' => true,\'show_in_menu\' => true,\'capability_type\' => \'post\',\'hierarchical\' => false,\'rewrite\' => array(\'slug\' => \'gaming\'),\'query_var\' => true,\'exclude_from_search\' => false,\'supports\' => array(\'title\',\'editor\',\'excerpt\',\'trackbacks\',\'custom-fields\',\'comments\',\'revisions\',\'thumbnail\',\'author\',\'page-attributes\',),\'taxonomies\' => array(\'category\',\'post_tag\',),\'labels\' => array (
  \'name\' => \'Gaming Posts\',
  \'singular_name\' => \'Gaming Post\',
  \'menu_name\' => \'Gaming Posts\',
  \'add_new\' => \'Add Gaming Post\',
  \'add_new_item\' => \'Add New Gaming Post\',
  \'edit\' => \'Edit\',
  \'edit_item\' => \'Edit Gaming Post\',
  \'new_item\' => \'New Gaming Post\',
  \'view\' => \'View Gaming Post\',
  \'view_item\' => \'View Gaming Post\',
  \'search_items\' => \'Search Gaming Posts\',
  \'not_found\' => \'No Gaming Posts Found\',
  \'not_found_in_trash\' => \'No Gaming Posts Found in Trash\',
  \'parent\' => \'Parent Gaming Post\',
),) );


//Blu-ray Custom Post Type
register_post_type(\'blu-ray_cp\', array( \'label\' => \'Blu-Ray Posts\',\'description\' => \'\',\'public\' => true,\'show_ui\' => true,\'show_in_menu\' => true,\'capability_type\' => \'post\',\'hierarchical\' => false,\'rewrite\' => array(\'slug\' => \'blu-ray\'),\'query_var\' => true,\'exclude_from_search\' => false,\'supports\' => array(\'title\',\'editor\',\'excerpt\',\'trackbacks\',\'custom-fields\',\'comments\',\'revisions\',\'thumbnail\',\'author\',\'page-attributes\',),\'taxonomies\' => array(\'category\',\'post_tag\',),\'labels\' => array (
  \'name\' => \'Blu-Ray Posts\',
  \'singular_name\' => \'Blu-Ray Post\',
  \'menu_name\' => \'Blu-Ray Posts\',
  \'add_new\' => \'Add Blu-Ray Post\',
  \'add_new_item\' => \'Add New Blu-Ray Post\',
  \'edit\' => \'Edit\',
  \'edit_item\' => \'Edit Blu-Ray Post\',
  \'new_item\' => \'New Blu-Ray Post\',
  \'view\' => \'View Blu-Ray Post\',
  \'view_item\' => \'View Blu-Ray Post\',
  \'search_items\' => \'Search Blu-Ray Posts\',
  \'not_found\' => \'No Blu-Ray Posts Found\',
  \'not_found_in_trash\' => \'No Blu-Ray Posts Found in Trash\',
  \'parent\' => \'Parent Blu-Ray Post\',
),) );


//TV Custom Post Type
register_post_type(\'tv_cp\', array(  \'label\' => \'TV Posts\',\'description\' => \'\',\'public\' => true,\'show_ui\' => true,\'show_in_menu\' => true,\'capability_type\' => \'post\',\'hierarchical\' => false,\'rewrite\' => array(\'slug\' => \'tv\'),\'query_var\' => true,\'exclude_from_search\' => false,\'supports\' => array(\'title\',\'editor\',\'excerpt\',\'trackbacks\',\'custom-fields\',\'comments\',\'revisions\',\'thumbnail\',\'author\',\'page-attributes\',),\'taxonomies\' => array(\'category\',\'post_tag\',),\'labels\' => array (
  \'name\' => \'TV Posts\',
  \'singular_name\' => \'TV Post\',
  \'menu_name\' => \'TV Posts\',
  \'add_new\' => \'Add TV Post\',
  \'add_new_item\' => \'Add New TV Post\',
  \'edit\' => \'Edit\',
  \'edit_item\' => \'Edit TV Post\',
  \'new_item\' => \'New TV Post\',
  \'view\' => \'View TV Post\',
  \'view_item\' => \'View TV Post\',
  \'search_items\' => \'Search TV Posts\',
  \'not_found\' => \'No TV Posts Found\',
  \'not_found_in_trash\' => \'No TV Posts Found in Trash\',
  \'parent\' => \'Parent TV Post\',
),) );

1 个回复
最合适的回答,由SO网友:s_ha_dum 整理而成

如果我明白你在做什么。。。

如果将categories设置为load at“/category name/”,将categories设置为load at“/movies/”,并将自定义帖子类型设置为load at“/movies/”,则存在冲突的元素。重写规则相互竞争。这将是一个问题。如果您设置has_archive 如果在注册帖子类型时为false,WordPress将不会创建“/电影/”存档页,这可能会让您前进一步(虽然您没有CPT的存档页),但您仍然混合了类别URL和自定义帖子类型URL,因此我预计还会有其他问题。

我的回答是:“我怀疑你是否能把这项工作做好,即使你能大致做到一些你可能不应该做到的功能”。

结束

相关推荐

未显示div和loop/php项的表

我知道这是一个荒谬的问题,因为谁还会用桌子?我得到了这个,只需要让它真正起作用。我对桌子一无所知,所以这是一次学习的经历。我终于找到了我的循环,但只是其中的一部分。我遗漏了一些重要的项目,无法解决。示例:显示文章标题,但它不是超链接。我试着把这些放在帖子里,但它们坏得很厉害,所以我用了pastebin。我想是因为桌子?英雄联盟博客php可在此处查看:http://pastebin.com/fYyhGMYa实时版本:http://elite.ikvclients.com/blog/非常感谢您的任何见解或帮助