Remove Category Name from Category’s URL using Code

Remove category text/name from category’s slug/url. Just paste given code on active theme’s functions.php. and category name automatically removed from category’s url.

Example with category name in URL

Example without category name in URL 

How to Do This

  • Open cpanel then open public_html.
  • Open wp-content then open themes folder.
  • Open active theme’s folder then open functions.php file.


function therkoyaard_remove_categoryname_from_url( $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', 'therkoyaard_remove_categoryname_from_url', 100, 2);
  • Paste given code and SAVE functions.php file.

Hope this code worked on your theme, Thanks for visiting