It is fun to reverse engineer databases. OK, you may have a different idea of fun. Here is the WordPress 2.5.1 database diagram from my server. See the online documentation for more details on tables and columns. This may help to clarify the previous post about tags.
One can find quite a few tag-related plug-ins for the WordPress, but adding tags to your old posts may prove to be quite a tedious task. Here is a simple method of adding tags to old posts, but this one is not for faint hearts—you have to run a SQL statement against the database.
Before you start
Back-up the database, better safe than sorry.
The following technique works only if the table wp_term_taxonomy has not been modified by a weird plug-in or manually; columns term_taxonomy_id and term_id should contain same numbers. To verify this, run the following:
SELECT COUNT(`term_taxonomy_id`) FROM `wp_term_taxonomy` WHERE `term_taxonomy_id` != `term_id`;
The result should be 0. If the returned result is greater than 0, do not use this procedure.
In the Manage–>Tags list, note IDs of your tags. Float the mouse pointer above the tag name to see the “ID” displayed in the status bar of your browser. For example, some of my tags:
Note IDs of your posts; floating the mouse pointer above a post name displays the “ID” in the status bar of the browser.
Create a table of associations between post and tag IDs.
Suppose we want to add tags “database” (id=18) and “data collection” (id=12) to the post Basic database checkup (id=95); tags “six sigma” (id=13) and “standard deviation” (id=14) to the post Mathematician with no diploma (id=45).
The table would look like this:
|Post ID||Tag ID|
Based on the previous table, add rows to the wp_term_relationships using the code snippet. If you have more rows just follow the pattern below the “VALUES” keyword. The third number within parentheses is always 0.
INSERT INTO `wp_term_relationships` (`object_id`, `term_taxonomy_id`, `term_order`) VALUES (95, 18, 0), (95, 12, 0), (45, 13, 0), (45, 14, 0);
Worked nice for me on WordPress 2.5.1.