php – 没有自定义帖子类型slug的WordPress slug
作者:互联网
我已使用以下代码注册自定义帖子类型:
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“movie”,比如默认情况下帖子和页面显示在前端?
谢谢
解决方法:
我认为没有直接解决方案.如果您需要这么糟糕,可以使用Custom Rewrite For Post Slug
标签:wordpress,php,url-rewriting,slug,custom-post-type 来源: https://codeday.me/bug/20190623/1267512.html