404更新到Wordpress 3.7后出现错误
今天早上我刚更新到WordPress 3.7,我的一个自定义帖子类型出现了404个错误。我通过一个插件实现了多个CPT。除了一个,其他所有的CPT都很好 其代码如下所示: //注册作者文章类型404更新到Wordpress 3.7后出现错误,wordpress,Wordpress,今天早上我刚更新到WordPress 3.7,我的一个自定义帖子类型出现了404个错误。我通过一个插件实现了多个CPT。除了一个,其他所有的CPT都很好 其代码如下所示: //注册作者文章类型 function custom_post_author() { $labels = array( 'name' => 'Authors', 'singular_name' => 'Author', 'add_new' => 'Add New', 'add_new_ite
function custom_post_author() {
$labels = array(
'name' => 'Authors',
'singular_name' => 'Author',
'add_new' => 'Add New',
'add_new_item' => 'Add New Author',
'edit_item' => 'Edit Author',
'new_item' => 'New Author',
'all_items' => 'All Authors',
'view_item' => 'View Author',
'search_items' => 'Search Authors',
'not_found' => 'No authors found',
'not_found_in_trash' => 'No authors found in Trash',
'parent_item_colon' => '',
'menu_name' => 'Authors'
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'authors' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'menu_icon' => plugins_url( 'images/authors.png', dirname( __FILE__ )),
'supports' => array( 'title', 'thumbnail', 'comments')
);
register_post_type( 'author', $args );
}
add_action( 'init', 'custom_post_author' );
CPT在后端是可见的,但是当我在前端查看任何帖子时,它给出了404。
关于如何解决这个问题有什么建议吗?我使用以下步骤解决了这个问题:
从WordPress
的菜单Settings->paramlinks
进入paramlink页面,通过单击save changes(或者您不需要更新设置,只需访问paramlinks
页面)更新设置(无需更改任何设置),然后尝试查看您的自定义帖子。它将显示。我使用以下步骤解决了此问题:
从
WordPress
的菜单Settings->paramlinks
进入paramlink页面,通过单击save changes(或者您不需要更新设置,只需访问paramlinks
页面)更新设置(无需更改任何设置),然后尝试查看您的自定义帖子。它会出现。WordPress 3.7似乎不喜欢将自定义帖子类型定义为作者。将其更改为authors
效果良好。但是,这也需要在wp_posts表中进行更新。WordPress 3.7似乎不喜欢将自定义post类型定义为作者。将其更改为authors
效果良好。但是,这也需要更新wp_posts表。我有一个非常类似的错误:我无法转到自定义帖子类型的任何单一页面。更新永久链接设置对我也没有帮助。我进行了一点调试,发现在$wp_rewrite->rewrite_rules()数组中没有设置自定义帖子类型的重写
我的所有自定义帖子类型都在插件中注册。然后我记得我曾经在文档中读到,您必须刷新插件激活/停用的规则(请参阅)
因此,我通过将flush_rewrite_rules()添加到注册所有自定义帖子类型的函数中,解决了我的问题,我认为这也会对您有所帮助
function register_my_custom_post_types()
{
register_post_type( ... );
// flush the rewrite_rules after registering the post types
flush_rewrite_rules();
}
我有一个非常类似的错误:我不能进入我的自定义帖子类型的任何单一页面。更新永久链接设置对我也没有帮助。我进行了一点调试,发现在$wp_rewrite->rewrite_rules()数组中没有设置自定义帖子类型的重写
我的所有自定义帖子类型都在插件中注册。然后我记得我曾经在文档中读到,您必须刷新插件激活/停用的规则(请参阅)
因此,我通过将flush_rewrite_rules()添加到注册所有自定义帖子类型的函数中,解决了我的问题,我认为这也会对您有所帮助
function register_my_custom_post_types()
{
register_post_type( ... );
// flush the rewrite_rules after registering the post types
flush_rewrite_rules();
}
我的问题已经通过这些步骤解决了,就发生在几分钟前。是的,我知道。。。更新永久链接解决了404个错误。WordPress 3.7似乎不喜欢将自定义帖子命名为作者
。我有同样的问题(更新为3.7)并已解决,但不知道还有什么问题。我的问题已通过这些步骤得到解决,并且发生在几分钟(30)前。是的,我知道。。。更新永久链接解决了404个错误。WordPress 3.7似乎不喜欢将自定义帖子命名为作者
。我遇到了同样的问题(更新为3.7)并解决了,但不知道还有什么问题。