Thanks again – I get it now!
John – that’s brilliant. I can’t believe how simple this solution turned out to be. I’m not sure if I understand it fully. isn’t it the main query that we’re trying to order? Thank you for your help on this!
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.
I’m experiencing this same issue. Has anyone addressed this?
The issue I am experiencing is changing the date in the date field on a post doesn’t save to the database. The original value remains. The date field simply won’t save and can’t be changed.
User error on my end – ignore my post!