Scriptfeeds Blog
  • Blog
  • WordPress
    • Woocommerce
    • WordPress Errors
    • WordPress Plugins
  • Development
    • WordPress Themes
  • Hire us
Cart / $0.00

No products in the cart.

No Result
View All Result
Scriptfeeds Blog
  • Blog
  • WordPress
    • Woocommerce
    • WordPress Errors
    • WordPress Plugins
  • Development
    • WordPress Themes
  • Hire us
Cart / $0.00

No products in the cart.

No Result
View All Result
Scriptfeeds Blog
No Result
View All Result
Home Wordpress

2 Quick ways to remove Category prefix from category pages url in WordPress

Scriptfeeds by Scriptfeeds
April 2, 2025
in Wordpress
0
84
SHARES
Share on FacebookShare on TwitterWhatsapp this Blog

The category prefix is part of the category archive pages URL slug. Removing the word category prefix from url shorten the url lenght which is also a part of SEO (If you category name is too big). Some developers and website owners also do it to maintain website aesthetics .

Well everybody has their own reason. this blog will guide you how to remove the category prefix from category URL with use of any plugin. We always recommend functionality without plugins.

The beauty of WordPress is that we can modify it as per our choice without hampering its core functionality.

Table of Contents

  • How default category page url looks
  • Option 1:
    • Removing Category prefix by Adding a Code in functions.php File
  • Option 2:
    • Modifying .htaccess to Remove Category prefix from category URL
      • Happy coding

How default category page url looks

Let’s have a look at an example of what it could look like if you do not remove a category from a category page URL: https://yoursite.com/category/category-name

remove Category prefix from category pages url

Option 1:

Removing Category prefix by Adding a Code in functions.php File

To add the code in function.php file. follow below setps:

  • Go to your WordPress dashboard.
  • Select Appearance >> Theme Editor.
  • Make sure child theme is selected
  • Find ‘functions.php’.
  • Save the function.php file, load the URL on frontend
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);

Option 2:

Modifying .htaccess to Remove Category prefix from category URL

You can access your .htaccess file either via FTP or cPanel/hpanel. If you can’t find the .htaccess file, check if your file manager is set up to show hidden files (dotfiles). if files are hidden, you have to select “Show hidden files from setting”

Follow the steps below

  • Go to your .htaccess file.
  • Add the below code after the closing tag in the file:
  • Use your domain name in place of www.site.com in the code below.
  • Upload it on your server’s public_html directory. replace the file if its ask.
RewriteRule ^category/(.+)$ http://www.site.com/$1 [R=301,L]

So that’s all folks. For anything else. You can connect our Dev here

Happy coding

Connect with Developer
Loading
Share34Tweet21Send

Leave a Reply Cancel reply

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

I agree to the Terms & Conditions and Privacy Policy.

Scriptfeeds Blog

© 2022 Scriptfeeds

Blog Categories

  • WordPress
  • Development
  • Reviews
  • Marketing

Connect us on

No Result
View All Result
  • Blog
  • WordPress
    • Woocommerce
    • WordPress Errors
    • WordPress Plugins
  • Development
    • WordPress Themes
  • Hire us

© 2022 Scriptfeeds

This website uses cookies. By continuing to use this website you are giving consent to cookies being used. Visit our Privacy and Cookie Policy.