Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove category & tag base from WordPress url - without a plugin

I would like to remove the category & tag base from WordPress URL. I have come across other posts and solutions which used plugins. I would like to stay away from plugins and have a solution from within functions.php. This would prevent any future plugin updates or WordPress default files from being changed.

Any help would be appreciated. Thanks!

I have tried these solutions so far:

  • This htaccess solution did not work: http://mikepayne.co/2011/remove-category-base-from-url/
  • These methods also failed: http://www.askapache.com/wordpress/remove-category-wordpress-urls.html
like image 577
cosmoonot Avatar asked Jul 22 '13 22:07

cosmoonot


People also ask

How do I remove a category from my WordPress URL?

Go to your WordPress dashboard. Select Yoast SEO >> Search Appearance>> Taxonomies. Go to Category URLs and select 'Remove the categories prefix'. Save the changes.

How do I remove categories in WordPress?

How to delete categories. To delete an existing category, hover over it and click the Delete button. You can't delete the default Uncategorized category. If you delete a category with posts filed in it, they will be assigned to the Uncategorized category.

How do I remove category category title from pages?

It's easy to do that. Simply open the functions. php file in your theme and add the following code at the end of the file: function prefix_category_title( $title ) { if ( is_category() ) { $title = single_cat_title( '', false ); } return $title; } add_filter( 'get_the_archive_title', 'prefix_category_title' );


2 Answers

If you want to remove /category/ from the url, follow these two steps:

  1. Go to Settings >> Permalinks and select Custom and enter: /%category%/%postname%/
  2. Next set your Category Base to .

Save it and you’ll see your URL changed to this format: http://yourblog.com/quotes/

(Source: http://premium.wpmudev.org/blog/daily-tip-quick-trick-to-remove-category-from-wordpress-url/)

like image 98
optimiertes Avatar answered Oct 13 '22 19:10

optimiertes


If you use Yoast SEO plugin just go to:

Search Appearance > Taxonomies > Category URLs. 

And select remove from Strip the category base (usually /category/) from the category URL.

Regarding the tag removal I did not found any solution yet.

like image 32
paulalexandru Avatar answered Oct 13 '22 18:10

paulalexandru