How can I modify the slug for the default wp posts without affecting other posttypes?

example: www.example.com/slug-of-post/ should become www.example.com/blog/slug-of-post/

I made a few custom post types where I rewrote the slug by using 'rewrite' => array('slug' => 'portfolio'), in the function.php file.

Result: www.example.com/post-type-slug/slug-of-post

I need the same result but for the default posts.



According to the docs: https://codex.wordpress.org/Using_Permalinks

Go to settings -> permalinks -> custom structure

and change that to: /blog/%postname%/

But please make sure that in your custom post types definition, (register_post_type) set

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

unless the URL of all of your custom post types will be prefixed by /blog/


As @rudtek mentioned in the comment, after your set 'with_front' => false, you must go to settings->permalinks and hit save again to flush rewrite rules. (This is the solution for many permalink issues)

  • I already tried that but it doesnt work.. – Jeroen Mar 3 '17 at 13:20
  • It DOES apply /blog to every post, while I did added the code to the other custom post types – Jeroen Mar 3 '17 at 13:21
  • @JeroenKnockaert did you set the with_front key to false for all of your custom post types? – pooria Mar 3 '17 at 13:22
  • yes I did. Any other ideas? – Jeroen Mar 3 '17 at 15:53
  • make sure that after you set with_front that you refresh your permalinks (ie go to settings/permalinks and hit save.) – rudtek Mar 3 '17 at 16:49

In extension to pooria's answer above:

If you are using the CPT UI plugin to manage your custom post types, there is a dropdown to toggle the with_front option:

"With Front" option on CPT UI plugin

By default this option is set to True so you will have to change it for all post types for which you want to start the permalink with your site URL.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.