WordPress post2cat to term_relationships

20080414535

Tags in WordPress meant a change to the database structure to better match posts to both categories and tags. Previously the relationship of what posts belonged to what categories was stored in a table named post2cat. Tags not only don’t make sense with the title but also require an additional column for order and a name change for the columns as tags don’t apply to just posts. This change destroyed the archive page counts and my simple counts plugin.

Here are the basics of what is different and how to update plugin queries from using post2cat to term_relationships.

  1. $wpdb->post2cat becomes $wpdb->term_relationships
  2. references to post_id column become object_id
  3. references to category_id column become term_taxonomy_id
  4. $wpdb->categories becomes $wpdb->terms
  5. references to cat_ID column become term_id

Skateboards and bikes are better at nights

Skateboards and bikes are better at nights. 0 comments.


Search WayTooCrowded
The Header Should Always Point Home