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.

  1. wp_terms
  2. wp_term_taxonomy
  3. wp_term_relationships
  1. 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.
  2. 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.
  3. 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:

Wordpress tag schema

Later, I will post the actual SQL/PHP code I use to duplicate my categories as tags. Stay tuned.

This entry was posted in Uncategorized and tagged , , , , , . Bookmark the permalink.
  • http://www.tiptail.com Cynthia Blue

    Just found this post via google… when I upgraded to 2.3 I mistakenly chose for WP to automatically convert my categories to tags. Well.. now I have tags that are numbers (23, 43, 45 etc) in the database. And I’m not sure how to clean these out. I don’t want to mess up the relationships. Using the Simple Tags plugin, they don’t show in my tag cloud, but when I use the default Tag Cloud they do show.

  • Josh Kenzer

    Under Manage->Manage Tags (part of the simple tag plugin), do you see your numbered tags?

  • http://www.tiptail.com Cynthia Blue

    I do see the numbered tags… I installed Simple Tags the Plugin and it has helped. However, it doesn’t automatically assign tags for untagged posts like it says it does.

  • http://www.radicalbehavior.com/copy-categories-to-tags-the-plugin/ Copy Categories to Tags – The Plugin

    [...] Part 2 of the previous WordPress Tag Post [...]

  • http://www.itcrossing.com/Blog/tabid/103/EntryID/184/language/en-US/Default.aspx On Tags and Categories – IT Crossing Blog

    [...] a third post, Rip links to another blog entry which highlights how keywords1 and categories are implemented in WordPress 2.3.  This really [...]

  • http://sulamita.linuxchix.org.br/index.php/upgrade-para-wordpress-26/ Toskices randômicas » Upgrade para Wordpress 2.6

    [...] era wp_categor*. Agora é wp_term*: wp_terms, wp_term_taxonomy e wp_term_relationships – leia aqui para mais detalhes. Então, comparando as entradas do backup – tabela wp_categories: [...]

  • http://sulamita.wordpress.com/2008/08/13/upgrade-para-wordpress-26/ Upgrade para Wordpress 2.6 « Sulamita’s Weblog

    [...] era wp_categor*. Agora é wp_term*: wp_terms, wp_term_taxonomy e wp_term_relationships – leia aqui para mais detalhes. Então, comparando as entradas do backup – tabela wp_categories: [...]

  • http://www.globalracingschools.com Racing Schools

    WordPress is already in 2.52 but the biggest problem is that the hosting companies can't keep up.

  • http://www.pimotor.com Parallel Import Car

    Before you try installing different versions of word press, make sure you back up all posts. The one thing that is important would be the backing up of comments. You need to export it properly.

  • http://www.painrelief.com.sg Knee Pain

    I'm a wordpress fanatic. Thanks for your tips.

  • http://www.breezeto5.com Managerial Job

    I just upgraded my WordPress to 2.7 only to realize that many of the plugins don't work in 2.7 and I had to spend the last 2 days testing multiple plugins. It's really time consuming.

  • http://www.silosobeachresort.com Singapore Hotel

    If you go to the official wordpress page, try clicking the plugins. There, you'll find the latest plugins that will work with the latest version of WordPress.

  • http://painrelief.sg/ physiotherapy

    wordpress is truely an amazing platform for democratic expression.

  • http://www.cancerhelps.com Obat Kanker

    I've tried WP 2.7 and it's simply awesome.

  • Valentin Perez

    nice article! nice site. you're in my rss feed now ;-)
    keep it up

  • William A Iuchs

    nice article! nice site. you're in my rss feed now ;-)
    keep it up

  • http://www.bethelshopfitting.com.au Shop Fitting

    When using WP 2.7 try using the official plugins recommended at the Official WordPress plugin section.

  • http://www.hsbc.co.uk/1/2personal/savings savings

    WordPress 2.7 is just the bomb. But make sure you have a back-up before installing the new version.

  • http://vip-pregnancy.blogspot.com pregnancy symptoms

    I wish to wish all pregnant women of good mood, easy pregnancy and natural sorts! Good luck also are happy! Give birth easily and independently! Let not doctors give birth for you, and you! Also adjust itself on chest feeding of the kid! Read the necessary information! Be, lovely pregnant mums and expecting posterities of the daddy, are healthy and wise!

  • http://xtremax.com SEO

    Though WordPress 2.3 is good but as soon as time passes, new innovations and enhancement in existing applications are very common and they are badly needed as well in this fast moving age.. WordPress 2.7 has come up with great enhancements but do take care of your backs while upgrading your WordPress..

  • http://www.googleshadowx.com/google-shadow-shocking-video/ Google Shadow

    Great article. Helps clear up a lot on the tagging confusing. You'll be surprise there are hell lot of people who doesn't know what tags are! :)

  • http://www.internet-empire.com Seo

    Nice relationship diagram for WordPress. Gives a clearer insight.

  • Jean J Abts

    you are on my rss reader now

  • kimdi

    I always had problems upgrading word press.

  • http://www.sightseeingtourslondon.com/original-london-sightseeing-tour-p-32.html Original London Tour

    Thanks for this. The main problem I have with WP is the upgrading process as it knocks out all of my currently installed plugins – its a real pain, therefore I am only on 2.4 still… and I want to be on 7 but I cannot be bothered with the hassle.

  • Ben

    I have nofollowed all my tag links. Having a silo structure is way better for a blog.
    I can only advice people to do this.

  • john191
  • http://www.wholesalediy.com/ Wholesale Electronics

    China Cheap Electronics Wholesale and Dropship: Cell Phones (http://www.wholesalediy.com/mobile-phone-c-6.html), MP4 Players, Car DVD Players, Gadgets, Spy Cameras, Computer Patrs, and more…

  • http://www.wholesalediy.com/ Wholesale Electronics

    China Cheap Electronics Wholesale and Dropship: Cell Phones (http://www.wholesalediy.com/mobile-phone-c-6.html), MP4 Players, Car DVD Players, Gadgets, Spy Cameras, Computer Patrs, and more…

blog comments powered by Disqus