WordPress.org

Ready to get started?Download WordPress

Forums

Where is post's category ID stored? (2 posts)

  1. rpastirik
    Member
    Posted 5 years ago #

    I was using a post's category ID to display posts from that category on a web page. Ex: Show all posts with a category ID of 10. The two mysql statements looked like: SELECT * FROM wp_post2cat WHERE category_id = '10'. Then: SELECT * FROM wp_posts WHERE ID = '$post_id'. It worked just fine until a recent upgrade. I've upgraded to version 2.7 and now all the database field names have changed and I can't seem to figure out where the category ID's are stored. (The description and ID data appears correct in the 'wp_term_taxonomy' table, but in the 'wp_posts' table, all the values in the 'post_category' field are set to '0'.) What tables and fields do I query to get my original functionality back? Where is the category ID stored for individual posts?

  2. MichaelH
    Member
    Posted 5 years ago #

    The terms taxonomy tables now house categories (both posts and links) and tags.

    The article Displaying_Posts_Using_a_Custom_Select_Query#Query based on Custom Field and Category has an example.

Topic Closed

This topic has been closed to new replies.

About this Topic