WordPress.org

Ready to get started?Download WordPress

Forums

custom query searching for specific category (2 posts)

  1. justinblayney
    Member
    Posted 1 year ago #

    Hello, I have a custom query which is working perfect so far. I want to add another condition, that it search for a specific category (87).. seems simple, but i am missing something. Below is my code

    $querystr = "
        SELECT $wpdb->posts.*
        FROM $wpdb->posts, $wpdb->postmeta
        WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id
       AND $wpdb->postmeta.meta_key = 'end_date'
       AND $wpdb->postmeta.meta_value > NOW()
        AND $wpdb->posts.post_status = 'publish'
        AND $wpdb->posts.post_type = 'post'
        AND $wpdb->posts.post_date < NOW()
    
        AND $wpdb->term_taxonomy.taxonomy = 'category'
      AND $wpdb->term_taxonomy.term_id = 87 	
    
        ORDER BY $wpdb->posts.post_date DESC
    
     ";
  2. justinblayney
    Member
    Posted 1 year ago #

    Any ideas? this seems like an easy one

Topic Closed

This topic has been closed to new replies.

About this Topic