How are Tags Implemented in Wordpress 2.3
As soon as Wordpress rolled out tagging in 2.3, I was done with categories. To me, categories feel so confining. I want to tag posts as I need to and not add full categories about something I only post about once or twice. Wordpress also rolled out a tool under categories to convert categories to tags. However, I get a fair amount of traffic to some of my category pages, so I don’t want to convert categories to tags, I want to duplicate them. Then I can hide the categories from the templates in favor of tags but still maintain those category pages for older content.
In order to copy categories to tags, I need to better understand how tagging is done in the database. There are three Wordpress tables that make up categories and tags. These tables also contain the names of your blog roll categories.
- wp_terms
- wp_term_taxonomy
- wp_term_relationships
- wp_terms: This table stores the actual category or tag name. It also stores the slug (the name used in the URL for category and tag pages). The slug is usually the lower case version of the tag with spaces replaced by dashes. There is also a term group field. I’m not sure how/where this is used.
- wp_term_taxonomy: This table defines if the term is a category, post_tag or link_category. For each item in your wp_terms table, there is an entry in the wp_term_taxonomy table. However, there may be multiple references to the wp_terms table. For example if you have category, tag and blogroll category named Internet, there will be one entry for Internet in the wp_terms table and three entries in the wp_term_taxonomy table. Also, if a category is a child category of another category, the parent category is stored in this table. The id stored in the parent category references the wp_term’s term_id, not the term_taxonomy_id – so it’s not exactly a recursive table.
- wp_term_relationships: This simple two column table maps the terms in wp_terms to the object – i.e. the blog post.
Here is a simple ERD of the relationships:

Later, I will post the actual SQL/PHP code I use to duplicate my categories as tags. Stay tuned.
-
Online Cricket Games
-
Parallel Import Cars
-
Back Pain
-
Singapore Hotel
-
Knee Pain
-
Obat Kanker
-
Shop Fitting
-
Cynthia Blue
-
Josh Kenzer
-
Cynthia Blue
-
physiotherapy
-
savings
-
SEO
-
billshadow
-
Upcoming fishing events
-
HotelBooker
-
Ben
