How to Add ‘/blog/’ Prefix in Blog Posts

Add blog to all the single posts permalink without writing a single line of code!

Sometimes we need to segregate different types of URL under some categories. Say for example you have a Woo Shop then you have /shop to identify a product or you have custom post type say services then you have /service, So now suppose we also need show all single blog posts under /blog then to achieve this we simply have to change the Permalink Settings.

To do this first login into WordPress admin panel and then navigate to

Dashboard > Settings > Permalinks

Under Common Settings section select Custom Structure and set it to /blog/%postname%/

wordpress append blog in post permalink

Now our single post page is setup, we now need to also add /blog to category and tag archive page, to this we need to alter Optional section field value. Set blog/category in Category base, and blog/tag in Tag base.

wordpress append blog in post category permalink

That it! we have set everything without writing a single line of code.

Just one important note if we have any custom post_type then we need to add with_front to false in rewrite, for example:

<?php
$labels = [
    "name" => __('Services', 'text-domain'),
    //…
    //…
];

$args = [
    "label" => __('Services', 'text-domain'),
    "labels" => $labels,
    //…
    //…
    "rewrite" => ["slug" => "service", "with_front" => FALSE], //<- SET with_front to FALSE
    //…
];
register_post_type("service", $args);

It's that's simple just a quick tips if we also need to add category name with blog to blog single post then we need to set Custom Structure to /blog/%category%/%postname%/.

wordpress append category in single post permalink
Raunak Gupta

Raunak Gupta

I'm Raunak Gupta, a seasoned software developer with over 9 years of experience in a wide range of programming languages, frameworks, and tools. I started my journey as a WordPress & CakePHP developer in 2014, diving deep into the world of OOPs, Request handling, and SEO. Along the way, I crafted numerous dazzling WooCommerce stores, tamed payment gateways, optimized for full filament functionality, and achieved ultra-low latency for lightning-fast load times. My expertise extends to BI tools, website builders, DevOps, and team leadership. I like to help upcoming developers, so I share my experience through this blog and by assisting fellow developers on Stack Overflow, where I've earned a stellar reputation with over 10k+ points of recognition.

Articles: 29

9 Comments

  1. Greetings! Quick question that’s totally off topic.
    Do you know how to make your site mobile friendly? My weblog looks
    weird when viewing from my iphone. I’m trying to find a theme or plugin that might be able to correct this issue.
    If you have any suggestions, please share. Thank you!

    • Hi @Bowie,

      For that you need little bit knowledge in HTML/CSS or you can hire developer from freelancer or guru.

  2. Excellent post. I was checking constantly this blog and I’m impressed!
    Extremely useful information specially the last part
    🙂 I care for such info a lot. I was seeking this particular info for a very long time.
    Thank you and good luck.

  3. Hi it’s me, I am also visiting this web site regularly, this site is
    actually nice and the users are genuinely sharing nice thoughts.

Leave a Reply

Your email address will not be published. Required fields are marked *