【发布时间】:2017-01-31 23:39:54
【问题描述】:
我已经使用以下代码注册了自定义帖子类型:
register_post_type(
array(
'labels' => // array of labels,
'public' => true,
'publicly_queryable'=> true,
'show_ui' => false,
'map_meta_cap' => true,
'show_in_menu' => false,
'query_var' => true,
'rewrite' => array( 'slug' => 'movie' ),
'capability_type' => 'post',
'has_archive' => false,
'exclude_from_search' => true,
'supports' => array('title'),
)
);
问题是,这个帖子的 URL 变成了:
http://yourdomain.com/movie/post_slug/
但是,我需要:
http://yourdomain.com/post_slug/
有没有办法从 URL 中删除帖子类型的 slug “电影”,比如帖子和页面默认显示在前端?
谢谢
【问题讨论】:
-
我已经在
'rewrite' => array( 'slug' => 'movie' )尝试过不同的参数,比如:用 false、Null、空字符串等替换“movie”,但它不起作用。
标签: php wordpress url-rewriting custom-post-type slug