WordPress resource site for WordPress Beginners with easy to understand WordPress tutorials for mastering the basics and beyond.

WordPress Guide

WordPress Guide

WordPress remove category from url

To remove category slug from existing posts, do this :

  1. Navigate to Settings > Permalinks and change Custom Structure from /%category%/%postname%/ to: /%postname%/
  2. Keep Category and Tag bases empty (which is the default also)
  3. Save

All posts can now be directly accessed via YourDomain.com/%postname%/ and all categories can be accessed via YourDomain.com/category/abc/. WordPress will automatically add all the 301 redirects for the old URLs. So, if someone accesses YourDomain.com/%category%/%postname%/ they will automatically get redirected to YourDomain.com/%postname%/

Remove Category in WordPress Permalinks

  • Go to your admin dashboard.
  • Go to Settings >> Permalinks >> Optional >> Category base.
  • Enter your customized category base (e.g. ‘Articles’) or Choose Post-name
  • Save the changes.

Removing Category by Adding a Code in functions.php File

  • Go to your WordPress dashboard.
  • Select Appearance >> Theme Editor.
  • Find ‘functions.php’.
  • Type the following code before the last PHP tag:
 function remove_category( $string, $type )  {           if ( $type != 'single' && $type == 'category' && ( strpos( $string, 'category' ) !== false ) )          {              $url_without_category = str_replace( "/category/", "/", $string );              return trailingslashit( $url_without_category );          }      return $string;  }     add_filter( 'user_trailingslashit', 'remove_category', 100, 2);

Using Yoast’s SEO Plugin to Remove Category from WordPress URL

  1. Go to your WordPress dashboard.
  2. Select Yoast SEO >> Search Appearance>> Taxonomies
  3. Go to Category URLs and select ‘Remove the categories prefix’.
  4. Save the changes.

Modifying .htaccess to Remove Category From WordPress URL

  • Login via FTP or cPanel
  • Go to your .htaccess file.
  • Add the following code after the closing tag in the file:
RewriteRule ^category/(.+)$ https://www.YourDomain.com/$1 [R=301,L]
  • Write your domain name in place of www.YourDomain.com or YourDomain.com in the code above.
  • Upload it on your server’s public_html directory.

Without plugin wordpress remove category from url

For Multisite WordPress the following works:

  1. Go to network admin sites;
  2. Open site under /;
  3. Go to settings;
  4. Under permalinks structure type /%category%/%postname%/. This will display your url as www.DomainName.com/categoryname/postname;
  5. Now go to your site dashboard (not network dashboard);
  6. Open settings;
  7. Open permalink. Do not save (the permalink will show uneditable field as www.DomainName.com/blog/. Ignore it. If you save now the work you did in step 4 will be overwritten. This step of opening permalink page but not saving in needed to update the database.