没有自定义帖子类型slug的WordPress slug [英] WordPress slug without custom post type slug

查看:120
本文介绍了没有自定义帖子类型slug的WordPress slug的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下代码注册了自定义帖子类型:

I have register custom post type with following code:

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'),
        )
);

问题在于,该帖子的网址变为:

The issue is that, the URL become for this post like:

http://yourdomain.com/movie/post_slug/

但是,我需要:

http://yourdomain.com/post_slug/

有什么方法可以从URL中删除帖子类型的电影,例如帖子和页面是否显示在前端

Is there any way to remove post type slug "movie" from URL, like posts and pages display at front-end by default?

谢谢

推荐答案

我不认为这是默认设置?直接解决这个问题。如果您非常需要此服务,则可以使用自定义重写后缀

I do not think there is straight forward solution this. If you need this so badly you can use Custom Rewrite For Post Slug

这篇关于没有自定义帖子类型slug的WordPress slug的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆