WordPress Post to Category ID association in the Database

WordPress 3

Start with a Post and get Category ID:

Get the id number(A) for the post you’re interested in in wp_posts table,  id column

Go to wp_term_relationships table, and find that same id number(A) in the object_id column, read over to the term_taxonomy_id column and get that number, that’s the category id

Start with a Category ID and get Category Name:

Go to the wp_terms table, and find the category you’d like in the name column, read over to the term_id and note the number

Find all Cateogry IDs:

Go to the wp_term_taxonomy table and sort by taxonomy value ‘category category number is in term_taxonomy_id column

Leave a Reply

You must be logged in to post a comment.