I recently found someone on the WordPress support forum who was asking how can he add /blog/
in front of his posts’, categories’ and tags’ URLs.
So I thought I’d write a post about it and share the solution with you guys. It’s quite easy actually.
Click here if you want to jump straight to the video tutorial.
Adding /blog/ to your posts’ URLs
You need to:
- Go to Settings -> Permalinks;
- Under Common Settings, choose Custom Structure. The default structure there would be http://yourdomain.com
/%postname%/
; - In front of
/%postname%/
, add/blog
, so it will become http://yourdomain.com/blog/%postname%/
; - Save changes.
Now, this should be it! Your posts’ URLs should begin with /blog/
, like on our testing website.
Adding /blog/ to your categories and tags too
The above change should work for your categories and tags too, so you shouldn’t do anything extra, but if it somehow doesn’t work, do this:
- In the same place, Settings -> Permalinks, go to Category base and Tag base, under Optional;
- Add this in Category base:
blog/category
and this in the Tag base:blog/tag
; - Save changes.
Video Tutorial
That’s a wrap
Hope you found the post useful!
Don’t forget to share it with your friends!
If you have any questions or thoughts, drop a comment, contact us, or message us on Facebook.
This will start applying blog in posts from custom post types as well, if have any.
What do we need to do to keep this for posts only.
Unfortunately, that will require some custom coding or a plugin, but I don’t think there’s a plugin that handles this situation in particular.
Thank you for the wonderful article.
I have followed the exact same steps and it is working as mentioned in the article.
Please help me in removing the ‘category’ slug from the url. Currently my url becomes:
mydomain.com/blog/category/mycategory-name.
The above works as mentioned but if i remove category from category base, it results in a 404 error. Please help me in resolving it. Our client has this requirement to append blog to all posts and categories, but ‘category’ slug is to be removed.
You have to use some custom code for that or a plugin, and the only plugin I know (that’s not outdated) that does that is Yoast SEO, which is a must-have plugin anyway, in my opinion. So, I recommend installing it and go to SEO > Search Appearance > Taxonomies > Category URLs > Remove the categories prefix.
Or, you can change ‘category’ to ‘topics’. Perhaps, the client will be willing to go with that.