我一直在浪费时间试图用自定义帖子类型解决永久链接问题。它不断返回未找到的页面(404)。当我使用默认的永久链接时,它会工作,但当我切换到post name时,它会中断。我尝试过更改slug名称、刷新重写、禁用所有插件、一个“自定义post-type permalink”插件,但都没有成功。
有人有类似的问题吗?我使用的是WordPress的最新4.0.1版本,下面是我的函数代码。php:
function authors_post_type() {
$labels = array(
\'name\' => _x(\'Authors\', \'post type general name\'),
\'singular_name\' => _x(\'Author\', \'post type singular name\'),
\'add_new\' => _x(\'Add New\', \'author\'),
\'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\'),
\'menu_name\' => __(\'Authors\')
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'menu_position\' => 5,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'query_var\' => true,
\'rewrite\' => array( \'slug\' => \'authors\' ),
\'capability_type\' => \'post\',
\'has_archive\' => true,
\'hierarchical\' => true,
\'menu_position\' => null,
\'supports\' => array( \'title\', \'editor\', \'author\', \'thumbnail\' )
);
register_post_type(\'authors\', $args);
}
add_action(\'init\', \'authors_post_type\');