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.
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:
- How to Add Products Per Page Dropdown in WooCommerce
- “Sorry, your session has expired. Return to homepage” – WordPress WooCommerce Error
- How to Create a Plugin in WordPress from Scratch
- ERROR: Cookies are blocked or not supported by your browser
- How To Send Custom Emails in WordPress
- How to Allow Preview of Draft Post Without Login in WordPress
- Import Users From CSV In WordPress Programmatically
- How to Redirect Users After Add To Cart In WooCommerce
- How to Remove the Category From URL in WordPress
- 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!
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…
I hope you are not using any caching plugins. If you are using any then try to repeat the same thing in the private window. Hope it will solve your problem
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?
Hi Luis, I think, you might forgot to re-save the permalinks
This breaks page. Error 404 on them.