Home › Forums › Add-ons › Repeater Field › pre_get_post and nested while loop › Reply To: pre_get_post and nested while loop
Thanks John. That’s not it (its actually a global that Learndash LMS creates)
Even when I use
add_action( 'pre_get_posts', 'my_change_sort_order');
function my_change_sort_order($query){
if(is_post_type_archive( 'sfwd-courses' )):
$query->set('orderby', 'meta_value');
$query->set('meta_key', 'expiry_date');
$query->set('order', 'DESC');
endif;
};
and I I check the output of archive-sfwd-courses.php, it does sort correctly (in this case according to descending expiry_date field) but it no longer displays the field presenter_info (the one in the nested while loop.)
All the fields show correctly when I do not use the pre_get_posts function.
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.