Remove the custom taxonomy slug from the URL in WordPress

Remove the custom taxonomy slug

If you are using WordPress and created a custom taxonomy for custom post type then this article is very helpful for you.

When you create a new custom taxonomy for custom post type or default post type in WordPress then its slug will show in the permalink URL structure. Adding slug to permalink displays the taxonomy slug of the current taxonomy and creates the URLs longer which is hard to remember. Also, it creates an issue to rank articles in Google or any search engine.

Also Read: Remove slug from custom post type in WordPress

How to remove the custom taxonomy slug

Let’s start with an example, Suppose I have created a custom taxonomy named “Course Category” for post type “Course”.

Now we will add a new “Course Category” with the name “Web Development”. When the course category will create in the database then we will try to open the course category page URL in the browser address bar.

It will look like the below link:

https://domain.com/course-category/web-development

Now you can see that adding the taxonomy slug creates URL longer and harder to remember.

I just wanted to be https://domain.com/web-development

So now I will cover all steps to remove the custom taxonomy slug from the URL to make the URL shorter and easy to remember.

It works for me, and it might work for you.

Are you want to get implementation help, or modify or extend the functionality of this script?

A Tutorialswebsite Expert can do it for you.

Remove slug in taxonomy url

You have to follow a few steps and set up the rules to do this task. The code is experimental and it is better to avoid using it at production sites. This is exactly what you need to remove the slug from the taxonomy slug.

Copy and paste the below code to your current theme functions.php file

Note: Please replace custom taxonomy name and slug with your own custom taxonomy name and slug

Update Permalink Setting

When all the above steps are done, Please update the wp-admin permalink link setting.

 After this Go to Settings > Permalinks and saving the permalink structure to end in /%postname%/ may also be necessary.

Remove the custom taxonomy slug

That’s it! Feel free to test the code and let me know if it’s not working in any particular case.

Wrapping Words!

Thanks for reading 🙏, I hope you found the Remove custom taxonomy slug in WordPress Without Plugin tutorial helpful for your project. Keep learning!. If you face any problem – I am here to solve your problems.

Are you want to get implementation help, or modify or extend the functionality of this script? Submit a paid service request

Related posts