admin管理员组

文章数量:1287856

My client wants to add /news/ at the beginning of the url of his blogposts, but doing so, it adds /news/ to the start of all post types.

Even trying to use some 'custom permalink' plugins, the /news/ is forced to all urls. No matter the type.

Is there a way to add something to the URL of the blogs, but not to the URL of other post types?

My client wants to add /news/ at the beginning of the url of his blogposts, but doing so, it adds /news/ to the start of all post types.

Even trying to use some 'custom permalink' plugins, the /news/ is forced to all urls. No matter the type.

Is there a way to add something to the URL of the blogs, but not to the URL of other post types?

Share Improve this question asked Sep 13, 2021 at 16:05 Fredy31Fredy31 8782 gold badges16 silver badges31 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

In creating your post types register_post_type) you need to add with_front as false:

'with_front' (bool) Whether the permastruct should be prepended with WP_Rewrite::$front. Default true.

so your rewrite could be

'rewrite' => array ( 'with_front' => false),

or if it's already there with a new slug something like this:

'rewrite' => array('slug' => 'post_slug', 'with_front' => false),

本文标签: permalinksAdding a prefix to the blogbut only the blog