isotropic-2022
Share
Blog
Search
Menu

How To Change The WordPress Posts Permalink To /blog/

By James LePage
 on May 3, 2020
Last modified on January 6th, 2022

How To Change The WordPress Posts Permalink To /blog/

By James LePage
 on May 3, 2020
Last modified on January 6th, 2022

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),
Code language: PHP (php)

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

Subscribe & Share
If you liked this content, subscribe for our monthly roundup of WordPress news, website inspiration, exclusive deals and interesting articles.
Unsubscribe at any time. We do not spam and will never sell or share your email.
Article By
James LePage
Contributors/Editors
notloggedin
James LePage is the founder of Isotropic Design, a digital agency that builds WordPress websites. I read, write and design constantly!
We're looking for new authors. Explore Isotropic Jobs.
Close
🇺🇸 English
Save posts, access exclusive content, join members-only communities and more.
Dark Mode Toggle
Love web dev? Join the Isotropic weekly newsletter.
cross linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram
0

Your Cart is Empty