{"id":4330,"date":"2025-04-02T18:11:10","date_gmt":"2025-04-02T18:11:10","guid":{"rendered":"https:\/\/scriptfeeds.com\/blog\/?p=4330"},"modified":"2025-04-12T19:32:31","modified_gmt":"2025-04-12T19:32:31","slug":"remove-category-prefix-from-url","status":"publish","type":"post","link":"https:\/\/scriptfeeds.com\/blog\/wordpress\/remove-category-prefix-from-url\/","title":{"rendered":"2 Quick ways to remove Category prefix from category pages url in WordPress"},"content":{"rendered":"\n<p>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 .<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>The beauty of WordPress is that we can modify it as per our choice without hampering its core functionality.<\/p>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>Table of Contents<\/h2><nav><ul><li><a href=\"#how-default-category-page-url-looks\">How default category page url looks<\/a><\/li><li><a href=\"#option-1\">Option 1:<\/a><ul><li><a href=\"#removing-category-by-adding-a-code-in-functions-php-file\">Removing Category prefix by Adding a Code in functions.php File<\/a><\/li><\/ul><\/li><li><a href=\"#option-2\">Option 2:<\/a><ul><li><a href=\"#modifying-htaccess-to-remove-category-from-word-press-url\">Modifying .htaccess to Remove Category prefix from category URL<\/a><ul><li><a href=\"#happy-coding\">Happy coding<\/a><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n\n\n<h2 class=\"wp-block-heading has-medium-font-size\" id=\"how-default-category-page-url-looks\"><strong>How default category page url looks<\/strong><\/h2>\n\n\n\n<p>Let&#8217;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<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1015\" height=\"295\" src=\"https:\/\/scriptfeeds.com\/blog\/wp-content\/uploads\/2025\/04\/image-3.png\" alt=\"remove Category prefix from category pages url \" class=\"wp-image-4636\" srcset=\"https:\/\/scriptfeeds.com\/blog\/wp-content\/uploads\/2025\/04\/image-3.png 1015w, https:\/\/scriptfeeds.com\/blog\/wp-content\/uploads\/2025\/04\/image-3-300x87.png 300w, https:\/\/scriptfeeds.com\/blog\/wp-content\/uploads\/2025\/04\/image-3-150x44.png 150w, https:\/\/scriptfeeds.com\/blog\/wp-content\/uploads\/2025\/04\/image-3-768x223.png 768w, https:\/\/scriptfeeds.com\/blog\/wp-content\/uploads\/2025\/04\/image-3-399x116.png 399w, https:\/\/scriptfeeds.com\/blog\/wp-content\/uploads\/2025\/04\/image-3-800x233.png 800w, https:\/\/scriptfeeds.com\/blog\/wp-content\/uploads\/2025\/04\/image-3-750x218.png 750w\" sizes=\"(max-width: 1015px) 100vw, 1015px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading has-large-font-size\" id=\"option-1\"><strong>Option 1:<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\" id=\"removing-category-by-adding-a-code-in-functions-php-file\"><strong>Removing Category prefix by Adding a Code in functions.php File<\/strong><\/h3>\n\n\n\n<p><strong>To add the code in function.php file. follow below setps:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go to your WordPress dashboard.<\/li>\n\n\n\n<li>Select Appearance &gt;&gt; Theme Editor.<\/li>\n\n\n\n<li>Make sure <strong><a href=\"https:\/\/wordpress.com\/support\/themes\/child-themes\/\" target=\"_blank\" rel=\"noopener\">child theme<\/a><\/strong> is selected<\/li>\n\n\n\n<li>Find \u2018functions.php\u2019.<\/li>\n\n\n\n<li>Save the function.php file, load the URL on frontend<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>function remove_category( $string, $type )  {           if ( $type != 'single' &amp;&amp; $type == 'category' &amp;&amp; ( 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);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-large-font-size\" id=\"option-2\"><strong>Option 2:<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading has-medium-font-size\" id=\"modifying-htaccess-to-remove-category-from-word-press-url\"><strong>Modifying .htaccess to Remove Category prefix from category URL<\/strong><\/h3>\n\n\n\n<p>You can access your .htaccess file either via FTP or cPanel\/hpanel. If you can&#8217;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 &#8220;Show hidden files from setting&#8221;<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Follow the steps below<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go to your .htaccess file.<\/li>\n\n\n\n<li>Add the below code after the closing tag in the file:<\/li>\n\n\n\n<li>Use your domain name in place of www.site.com in the code below.<\/li>\n\n\n\n<li>Upload it on your server&#8217;s public_html directory. replace the file if its ask.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>RewriteRule ^category\/(.+)$ http:\/\/www.site.com\/$1 &#91;R=301,L]<\/code><\/pre>\n\n\n\n<p>So that&#8217;s all folks. For anything else. You can <strong><a href=\"https:\/\/scriptfeeds.com\/blog\/hire-us\/\" data-type=\"page\" data-id=\"3537\">connect our Dev here<\/a><\/strong><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"happy-coding\"><strong>Happy coding<\/strong><\/h4>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4304,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jnews-multi-image_gallery":[],"jnews_single_post":{"format":"standard"},"jnews_primary_category":[],"footnotes":""},"categories":[75],"tags":[],"class_list":["post-4330","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-wordpress"],"_links":{"self":[{"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/posts\/4330","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/comments?post=4330"}],"version-history":[{"count":0,"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/posts\/4330\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/media\/4304"}],"wp:attachment":[{"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/media?parent=4330"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/categories?post=4330"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/tags?post=4330"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}