How To Change The WordPress Posts Permalink To /blog/

Published: 9 months ago

Changing the permalink to display /blog/ before the post specific information is a difficult task if you have custom post types in your site, as the "standard" way of doing things applies to all post types.

Here's the issue. You want to change isotropic.co/super-cool-blog-post to be isotropic.co/blog/super-cool-blog-post.

First, if you're not running custom post types, here's how to change the slug to show blog.

Simply go to Settings --> Permalinks and add this custom permalink structure:

/blog/%postname%/

Click save, and you've got a blog in your slug.

The default to change this way works well if you're not running custom post types, but if you are, it ruins the slug. Here's what I mean.

Assume you have a custom post type for /services. If you change all post permalinks to show /blog/post-title, then your slug for services becomes /blog/services/service-title. We only want the new blog permalink structure to apply to blog posts.

With custom posts, the best way to fix this issue is to turn off "Front Matter". You do this by adding a PHP snippet. Simple set "with_front" to false. For example, if we had services as a custom post type, and didn't want our /blog permalink structure to apply for it, we'd add this code:

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

The way to add this code is super simple. We use a plugin called Code Snippets -- simply install it, paste the code into a new Snippet, then save and activate it. Go back to your permalink settings and click "save" to flush the previous settings.

Read more here: https://codex.wordpress.org/Function_Reference/register_post_type

Join Our Newsletter
Here's what you get: A once a week newsletter that contains original content, aggregated posts, WordPress deals, and anything else we think you'd like. We don't spam or sell your email address. Unsub at any time.

Affiliate Disclosure: Some links on this website are affiliate links. We make commissions for purchases made through those links.

We only recommend items/tools that we've personally used and like.

Full Disclosure | FTC Statement

Join Our Newsletter
Over 4,000 Design Lovers and Problem Solvers.

Author

  • James LePage is the founder of Isotropic Design, a digital agency that builds WordPress websites. I read, write and design constantly!

A relationship driven website creation company.

Connect

© ISOTROPIC, LLC 2016-2021
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram