Hello.
I’m trying to find a solution for this challenge. I’m pulling in some posts based on an ACF field, “state” which value is obtained from the URL. That part works fine.
Now, I’d like to find a way to sort $posts by “organization” which is also an ACF field. How can I filter results by one meta_value, and sort by another one? Every tip
$state_from_URL = $_GET['state'];
$posts = get_posts( array(
'numberposts' => -1,
'post_type' => 'post',
'meta_key' => 'state',
'meta_value' => $state_from_URL,
'orderby' => 'organization',
'order' => 'ASC',
));
I appreciate any help or tips!
This can be done using clauses like I outlined here https://support.advancedcustomfields.com/forums/topic/sort-by-one-field-and-then-by-another/#post-52147
Edit: maybe not exactly like I outlined there, but the principle is the same and you should be able to do this using clauses.