Hello I am doing a custom query for all posts in a particular category (cat_ID = 329) that have a custom key ('agendadate') and then the results are sorted by the values of that custom key.
I would now like to add a statement so the query omits posts whose ids are listed in a previously created array called $exclude.
Is this possible?
Here is what I was thinking for the custom query string (the line in question is the 3rd AND statement):
$querystr = "
SELECT * FROM $wpdb->posts
LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id)
LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)
LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
WHERE $wpdb->term_taxonomy.term_id = 329
AND $wpdb->term_taxonomy.taxonomy = 'category'
AND $wpdb->posts.post_status = 'publish'
AND $wpdb->posts.ID != $exclude
AND $wpdb->postmeta.meta_key = 'agendadate'
AND $wpdb->postmeta.meta_value >= $today
ORDER BY $wpdb->postmeta.meta_value ASC ";
$show = $wpdb->get_results($querystr, OBJECT);
The != operator doesn't seem to work and I don't really know SQL. It doesn't work for single post IDs either.
Any suggestions? Thanks.