WordPress Tip: add ‘blog’ in front of your blog URLs
Some people still think of WordPress as a blogging platform. But the last time we built a WordPress site for a blog-oriented site was years ago.
Some features of WordPress are still remnants from its blogging background. By default, your front page is your ‘latest posts’ page, and the Permalinks put your blogs right at the top of your links (http://yoursite.com/2015/04/22/your-post).
Unless your website is a blog, you probably use a static page on front, and display your blogs on a separate page (yoursite.com/blog). To keep your permalinks intuitive, you could move your posts under your blogs page too (yoursite.com/blog/2015/04/22/your-post). Here is how to do it:
Adding ‘blog’ to your links
In the Permalinks settings (WP Admin → Settings → Permalinks) select “Custom Structure”. It should display your current structure in the text box next to it.
/blog in front of what is in the text box (including the slash in front!). You can change the word blog if you want something different.
Next, we’ll also add the new base in front of the category and tag URLs. If the text boxes are empty, fill them with
If you already have custom category and tag bases, put
blog/ in front of what you already have (note that this time there is no slash in front).
And that’s it. Your blogs will now have
blog/ in front of them, while your pages remain unchanged!
Custom post types
If you are using custom post types on your site, you need to make sure that ‘rewrite with front’ is disabled for each of your post types. Otherwise your custom post type URLs will also get
/blog/ in front of them.
If you use a plugin to register your post types, look for the ‘Rewrite‘ option, and make sure that ‘With Front‘ is unchecked. After saving your settings, go back to the Permalinks Settings and click ‘Save Changes’ (this is necessary so that the new links are generated).
If this doesn’t work, also fill out the ‘Slug’ in your post type ‘Rewrite’ settings. Some plugins require this for the ‘With Front’ option to work (and again, save your permalink settings!).
If you have defined your own custom post types in your code, make sure that when registering your post type, you have disabled
rewrite["with_front"], like this:
register_post_type( 'my_post_type', array( [...] "rewrite" => array( "with_front" => false ) [...] ) );
Remember to save your permalink settings in WP Admin after changing your rewrite rules!