Forums

where is cat id in database? (5 posts)

  1. axxxon
    Member
    Posted 2 years ago #

    hello!
    i'm using the following code to retrive titles and ids of posts from my database.

    $ids = $wpdb->get_col("SELECT id FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'");
    $titles= $wpdb->get_col("SELECT post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'");

    i want make it to select $ids and $titles for only one category, but i could't find specific field.
    So can anyone point me where(which table and filed name)is cat id for post?

  2. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

  3. Joseph
    Member
    Posted 2 years ago #

    Category information are stored across three tables, wp_terms, wp_term_taxonomy, and wp_term_relationships.

    It's better to do a triple join between the three plus the post table.

  4. axxxon
    Member
    Posted 2 years ago #

    thank's Joseph that's what i've been searching for!

  5. Joseph
    Member
    Posted 2 years ago #

    You're welcome.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags