自定义帖子类型的固定链接在帖子名称前添加帖子类型的名称
问题描述:
因此,我创建了一个自定义帖子类型,它似乎可以正常工作。自定义帖子类型的固定链接在帖子名称前添加帖子类型的名称
但是,创建帖子的固定链接具有帖子名称前面的自定义帖子类型的名称。
我越来越喜欢地址: http://demoforhim2.e-ddl.com/movie_reviews/secondone/
,并试图改变这种状况到:http://demoforhim2.e-ddl.com/secondone/
我已经使用重写空塞尝试,但没有奏效。
这里是我的自定义后类型
add_action('init', 'create_movie_review');
function create_movie_review() {
register_post_type('movie_reviews',
array(
'labels' => array(
'name' => 'Movie Reviews',
'singular_name' => 'Movie Review',
'add_new' => 'Add New',
'add_new_item' => 'Add New Movie Review',
'edit' => 'Edit',
'edit_item' => 'Edit Movie Review',
'new_item' => 'New Movie Review',
'view' => 'View',
'view_item' => 'View Movie Review',
'search_items' => 'Search Movie Reviews',
'not_found' => 'No Movie Reviews found',
'not_found_in_trash' => 'No Movie Reviews found in Trash',
'parent' => 'Parent Movie Review'
),
'public' => true,
'menu_position' => 15,
'supports' => array('title', 'editor', 'comments', 'thumbnail'),
'taxonomies' => array(''),
'menu_icon' => plugins_url('images/16x16.png', __FILE__),
'has_archive' => true,
'rewrite' => array('slug' => '', 'with_front' => FALSE) /*doesnt seem to work*/
)
);
}
由于某种原因,上述工作不正常。
答
尝试......
'rewrite' => array('slug' => '/')
输出:example.com/headline/
弹头取出,没有多余的斜线。
记住刷新固定链接(设置 - >永久链接)
来源:http://wordpress.org/support/topic/how-can-i-create-a-custom-post-type-with-empty-slug
是啊,但应该有一个方法来消除它。和URL示例将http://demoforhim2.e-ddl.com/movie_reviews/secondone/我想摆脱movie_reviews。 –
将slug设置为false而不是“'。资料来源:http://wordpress.stackexchange.com/questions/6832/how-do-you-remove-slug-altogether-from-custom-post-type –
我不知道这是否会奏效。似乎已经为OP而工作,但不为其他人。无论如何,我认为wordpress.SE在他们的存档中会比Stackoverflow更多。 –