remove blog word from wordpress permalink url

remove blog word from wordpress permalink url

Many times we need to remove the category or blog slug from wordpress URL.  We can very easily remove the blog word from wordpress blog URL. In this tutorial, We are going to show remove blog word from wordpress permalink url. this is useful when you upgraded your wordpress multisite installation.

remove blog word from wordpress permalink url

I personally used wordpress mu for long time. When wordpress 3.0 launched with multisite functionality we started using wordpress 3.0. Removing blog and category slug is very important for many clients.

I am assuming you are using wordpress 3.0 multisite installation. If that is so then you need to do following action.

First login to wordpress admin and go to Super Admin > Sites > Edit

and Scroll down to “Permalink Structure” and remove the “/blog” part. That should work.

Image is shown as like.

remove blog word from wordpress permalink url
remove blog word from wordpress permalink url

than update the option and your issue will be solved. If you are still facing issue then you need to use following code in your functions.php file. Following code is useful for those who updated wordpress mu from wordpress 3.0, other wise they can use above action.


add_filter("pre_update_option_category_base","remove_blog_slug");
add_filter("pre_update_option_tag_base","remove_blog_slug");
add_filter("pre_update_option_permalink_structure","remove_blog_slug");

/* just check if the current structure begins with /blog/ remove that and return the stripped structure */
function remove_blog_slug($tag_cat_permalink){

if(!preg_match("/^\/blog\//",$tag_cat_permalink))
return $tag_cat_permalink;

$new_permalink=preg_replace ("/^\/blog\//","/",$tag_cat_permalink );
return $new_permalink;

}

If you want advanced permalinks then I can suggest following wordpress plugin for changing the permalink

Advanced Permalinks

advanced permalink options that allow you to:

  • Have multiple permalink structures. Permalinks can be assigned to posts or ranges of posts
  • 301 redirect old permalink structures (many structures are allowed)
  • Category-specific permalinks. Posts in certain categories can be assigned a permalink structure
  • No need to have a base to the category permalink!
  • Change author permalinks
  • Enable periods in permalinks – perfect for migrating old websites

If you need more information or help then you can contact me through contact form.

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

10 thoughts on “remove blog word from wordpress permalink url”

  1. Thank you, Purab!
    I spent several hours trying to remove the blog slug and nothing worked. I found your beautiful code and it works like a charm. You are a star!

Leave a Reply to Purab Kharat Cancel reply

Your email address will not be published.