I have this custom query that get the expiry date of the post and orders post by that. How do I amend it to only list from a certain category id e.g. '20'
$querystr = "
SELECT wposts.*
FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
WHERE wposts.ID = wpostmeta.post_id
AND wpostmeta.meta_key = 'es_ape_expiry'
ORDER BY wpostmeta.meta_value ASC
";
$pageposts = $wpdb->get_results($querystr, OBJECT);
Many Thanks !
Try following query and replace $cat_id with 20