In this tutorial, you will learn how to change a custom taxonomy slug in WordPress easily and quickly without using plugins. Of course, you can make changes to the code of the registration custom taxonomy, but it is not always easy and expedient to do it. Consider an example of how to do this by adding several lines of code to the functions.php file in your WordPress theme.
Before making any changes, be sure to backup your website (database and files).
How to change a custom taxonomy slug without a plugin
All the necessary actions do on the example of our Mercury theme. It has a custom post type “Games” that contain a custom taxonomy “Categories” with the “game-category” slug.
1) Go to “Appearance” – “Theme Editor“. Select functions.php theme file. Paste this code at the end of the file.
Instead of the “old-slug“, add a current slug of the custom taxonomy, which you want to change. And instead of the “new-slug“, add a new slug name.
But try to edit the theme files not through the Theme Editor, but with the help of special source code editors, such as Sublime Text or Notepad++. Then upload the modified files via FTP.
2) Go to “Settings” – “Permalinks“. Click the “Save Changes” button. This must be done for the new slug to start working.
Photo by Ryan Stone on Unsplash
Is it possible to change old-slug to new-slug from database table? If yes, how?
We have not considered this method.