如果我启用了永久链接,我对自定义帖子类型“草稿”帖子预览重定向到网站主页有问题。
例如,我创建一个新的“项目”,另存为草稿,然后单击预览。预览窗口将打开到站点主页。
如果我将site permalinks设置为“default”,它将正常工作。
这是我注册帖子类型的代码。根据register_post_type codex entry, 我尝试了“query\\u var”(真/假/“projects”)的不同设置,但没有任何不同。我还尝试编辑重写参数和/或将其全部删除。不行。谢谢你的帮助!
UPDATE: 我已经确认,这是过去的工作,并打破了最近的更新。我猜这是register\\u post\\u type codex页面的“Public\\u queryable”部分提到的对4.2.2的更新,但直到刚才才有人注意到。
// Project
$labels = array(
\'name\' => \'Projects\',
\'singular_name\' => \'Project\',
\'menu_name\' => \'Projects\',
\'parent_item_colon\' => \'Parent Project:\',
\'all_items\' => \'All Projects\',
\'view_item\' => \'View Project\',
\'add_new_item\' => \'Add New Project\',
\'add_new\' => \'Add New\',
\'edit_item\' => \'Edit Project\',
\'update_item\' => \'Update Project\',
\'search_items\' => \'Search Project\',
\'not_found\' => \'Not found\',
\'not_found_in_trash\' => \'Not found in Trash\',
);
$rewrite = array(
\'slug\' => \'projects\',
\'with_front\' => true,
\'hierarchical\' => true,
);
$args = array(
\'label\' => \'Project\',
\'description\' => \'Individual Projects\',
\'labels\' => $labels,
\'supports\' => array( \'title\', \'editor\', \'revisions\', \'author\'),
\'taxonomies\' => array( \'project_categories\', \'project_sponsors\' ),
\'hierarchical\' => false,
\'public\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'show_in_nav_menus\' => true,
\'show_in_admin_bar\' => true,
\'menu_position\' => 20,
\'menu_icon\' => \'dashicons-clipboard\',
\'can_export\' => true,
\'has_archive\' => true,
\'exclude_from_search\' => false,
\'publicly_queryable\' => true,
\'capability_type\' => \'page\',
\'rewrite\' => $rewrite,
\'query_var\' => \'projects\',
);
register_post_type( \'projects\', $args );