Home › Forums › ACF PRO › meta_query doesn't work for filter a query by an ACF value and order by another › Reply To: meta_query doesn't work for filter a query by an ACF value and order by another
Hi, Noone responds but I try to use pre_get_posts:
function my_pre_get_posts( $expo_query ) {
// do not modify queries in the admin
if( is_admin() ) {
return $expo_query ;
}
// only modify queries for 'exposiciones' post type
if( isset($expo_query ->query_vars['post_type']) && $expo_query ->query_vars['post_type'] == 'exposiciones' ) {
$expo_query ->set('meta_key', 'expo_start_date');
$expo_query ->set('orderby', 'meta_value');
$expo_query ->set('order', 'DESC');
}
// return
return $expo_query ;
}
add_action('pre_get_posts', 'my_pre_get_posts');
without success. 🙁
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.