Support » Fixing WordPress » custom query searching for specific category

  • 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
    
     ";
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘custom query searching for specific category’ is closed to new replies.