Home » Remove Custom Taxonomy Base From URL In WordPress

Remove Custom Taxonomy Base From URL In WordPress

Last updated on December 24, 2020 by

Sometimes, an SEO point of view requires to remove custom Taxonomy base from the URL in WordPress.

Table of Contents
1. What We Would Like to Achieve?
2. Solution
3. The Most Important Thing That You Have to Do After Code Change

By default, the inbuilt post has Category & Tags which refer to Taxonomy into the Custom Post Type. Occasionally, We need to create the Custom Post Type with Taxonomy (Category or Tags) to extend the feature of the site.

Now, the site requires to show posts based on Category or Tags (Taxonomy). You have done that but if you look carefully at the URL, there is that Taxonomy (Category or Tags) slug appear which looks ugly in terms of SEO. Now, what to do? In such a case try the following solution.

What We Would Like to Achieve?

Please check this screenshot and ensure that what we are going to do in this article.

Remove Custom Taxonomy Base from URL in WordPress
Remove the taxonomy base of CPT from the URL

Solution

Add the below code into your taxonomy registration.

'rewrite' => array(
       'slug' => '/',
       'with_front' => false
 )

The Most Important Thing That You Have to Do After Code Change

After you’ve altered your custom post type taxonomy document, try to go to Settings > Permalinks and re-save your settings, else you will get 404 pages not found.

Additionally, read our guide:

  1. How to Add Products Per Page Dropdown in WooCommerce
  2. “Sorry, your session has expired. Return to homepage” – WordPress WooCommerce Error
  3. How to Create a Plugin in WordPress from Scratch
  4. ERROR: Cookies are blocked or not supported by your browser
  5. How To Send Custom Emails in WordPress
  6. How to Allow Preview of Draft Post Without Login in WordPress
  7. Import Users From CSV In WordPress Programmatically
  8. How to Redirect Users After Add To Cart In WooCommerce
  9. How to Remove the Category From URL in WordPress
  10. How to Add Custom Column To Any Post Types in WordPress

That’s it for now. We hope this article helped you to learn how to remove custom taxonomy base from URL in WordPress.

Please let us know in the comments if everything worked as expected or your issues or any questions. If you think this article saved your time & money, please do comment, share, like & subscribe. Thank you for reading the post. Keep Smiling 🙂 & Keep Coding!

 
 

5 thoughts on “Remove Custom Taxonomy Base From URL In WordPress”

  1. I did exactly what you say. the custom taxonomy slug was remove but even after updating the permalink structure i keep receiving 404 on normal pages like contact…

    Reply
  2. Hello, thank for your post, it has been useful to me but now I have an issue: I have 2 different taxonomies which I want no taxonomy base.

    I’ve added your code to both taxonomies but now WordPress seems lost: it looks like WordPress don’t know the taxonomy a term belongs to.

    Do you have any ideas about this issue? How could I solve this?

    Reply

Leave a Comment