我今天早上刚刚更新到WordPress 3.7,并且在一种自定义帖子类型上开始出现404错误。我正在通过一个插件实现多个CPT。除一个以外,所有其他CPT都正常。
相同的代码如下:
//注册作者帖子类型
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 3.7不喜欢将自定义帖子类型定义为author
。将其更改authors
为工作正常。但是,这还需要在wp_posts表中进行更新。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句