I’ve looked at this codex page, but am unsure how to select posts based on the values of two custom fields, rather than one, as explained in the examples on that page.
Here is the code I tried, which failed, probably because it doesn’t state which meta value goes with which meta key.
Can anyone clarify, or provide correct code to do this? I want to find posts where the values $plowset and $phiset are within the range of the custom fields price_low and price_high.
$querystr = "
FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
WHERE wposts.ID = wpostmeta.post_id
AND wpostmeta.meta_key = 'price_low'
AND wpostmeta.meta_value >= ".$plowset."
AND wpostmeta.meta_key = 'price_high'
AND wpostmeta.meta_value <= ".$phiset."
AND wposts.post_status = 'publish'
AND wposts.post_type = 'post'
AND wposts.post_date < NOW()
ORDER BY wposts.post_date DESC