How do i filter posts by one custom field and order by another custom field?
-
After looking at this:
https://www.ads-software.com/support/topic/203210?replies=9
and this:
https://codex.www.ads-software.com/Displaying_Posts_Using_a_Custom_Select_Query
I managed to retrieve posts by a custom field called “Backlab Artists”.
Now, I want it to sort by a second custom field called “rs_event”, which isn’t working.
Code looks like this:
`
$querystr = “
SELECT wposts.*
FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
WHERE wposts.ID = wpostmeta.post_id
AND wpostmeta.meta_key = ‘Backlab Artists’
AND wpostmeta.meta_value = ‘”.$name.”‘
AND wposts.post_type = ‘post’
AND wposts.post_status = ‘publish’
ORDER BY wpostmeta.meta_value DESC
“;Thanks for your help!
- The topic ‘How do i filter posts by one custom field and order by another custom field?’ is closed to new replies.