0

My site has a few custom post types each with their own base slugs (e.g. /workouts/, /trainers/, etc). I would like to give the default WordPress blog posts their own base slug (e.g. /blog/) without affecting the base slug of the other custom post types.

Whenever I change the permalink structure in Settings->Permalinks to "/blog/%postname%" it affects all posts, so my other paths become "/blog/workouts/", "/blog/trainers/", etc.

Is there a way to move only the base slug for the default WordPress blog posts? So I would have the archive on /blog/ and the posts like /blog/some-post-title/

Is the only way to create yet another custom post type?

1 Answer 1

2

For this, you need to alter the way you register your custom post type to not use the "front" of your URL structure (like "blog") for the URLs of that custom post type. You need to add this to your arguments array for the register_post_type() call:

'rewrite' => array(
     'with_front' => false,
),
4
  • don't forget to reset your permalinks after this change by visiting settings/permalinks.
    – rudtek
    Jan 28, 2018 at 19:21
  • Thanks, that worked! Do I need to create a fake page to get the default post archive on /blog/ instead of /? Also, is it better for me to just create a custom post type? I'm thinking this might give me more flexibility in the future, and just leave the default WP posts unused and alone...
    – Ralph
    Jan 28, 2018 at 19:29
  • If you change your URL structure to include /blog in front, your posts should be fine. The /blog URL is your home page (an empty page set as Posts Page in Settings -> Reading).
    – Vlad Olaru
    Jan 29, 2018 at 14:12
  • Thanks @VladOlaru, creating a blank page (e.g. "Blog") and then changing Settings -> Reading -> Posts page to "Blog" makes the /blog/ path work. Note for others: it uses the archive.php template by default.
    – Ralph
    Feb 13, 2018 at 6:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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