How to add a slug to your WordPress posts without adding it to custom post types

August 20, 2015
Posted in: Code Snippets, How To, Web Development, WordPress

We’re finding that our clients’ sites are more and more often websites first, and blogs second.  As such, typical landing pages are placed in the root, and their children are placed beneath them in the URL hierarchy like this:

  • Product Landing Page:
  • Product Detail Page:

With this structure in place, clients expect their WordPress blog to use a similar format:

  • Blog Landing Page:
  • Blog Post Page:

Fortunately, this is pretty quick to do for your site using WordPress’ permalinks settings.  Just set your custom permalink structure to:


If you have any custom post types used on your site, you’ll need to make sure that they don’t get the /blog/ prepended to their URLs.  To remove it, simply set with_front to false where the custom post types are registered:

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

You should also flush the WordPress rewrite rules after making this change – just go back to Settings > Permalinks and hit save.

Scott Buckingham

President / Owner
613-801-1350 x101
[email protected]
Scott is a WordPress expert who has worked on hundreds of web design and development projects. He excels at finding creative ways to solve technical problems. View full profile