It’s hard to know what the future will be. When initially building out a site, it’s a game of guesswork to name things. You want to name them to be long term sustainable, but without a crystal ball, there will be missteps.
Take, for example, the case of custom taxonomies. When my site was originally built out, it only had one custom set of tags and they were logically called
sitename_tags. As the site grew, it became apparent that multiple tags were going to be needed and, in the end, it had five.
What Are Our Names
While it’s relatively easy to rename a taxonomy’s display name by editing the data in
register_taxonomy, you don’t want to rename the
rewrite after the fact. You can do it, of course, but I recommend you be really up to speed on your redirects before you try. Obviously the best choice is to pick good names in the beginning. But what names are we actually talking about?
- The Display Name – This is the name your readers (and you) see. Categories and Tags are display names. In my case, Stations, Clichés, and Tropes are display names. You can change these as you need.
- The Slug – This is the rewrite I mentioned. It’s in your URL. Don’t change this unless you know redirects.
- The Taxonomy Name – This is secret. You’d only know what it was if you hovered over the links and noticed that tags have a taxonomy of
Today we’re talking about that third one.
If you’re the only one who really sees that you named your stations
show_tag instead of
show_station, why does it matter?
As it turns out, if you’re working on the theme and plugins for a site, you will end up running into those quirks when you write a loop to perform complex displays on your data. It’s both annoying to have to always comment things like “Yes show_tag means show_station” so that future you knows what the hell you’re doing.
Like my friend says, the best documentation for a function is a good name, and fixing the name will make you feel better and smarter.
How To Do It
This requires two steps:
1) Run a search/replace on your files to swap the names out
2) Run a search/replace on your database to swap the names out
The reason is that those two things have to be in sync. Since my world lives in a git repo and a server with WP-CLI, I ran a search/replace on my files, pushed the changes, and then ran a quick
wp search-replace show_tag show_station to clean it up.
The important thing to note is that what you’re changing in your database is not post content, but meta information and tags tables.