Forums › Forums › Search & Filter Pro › Meta sort order
- This topic has 7 replies, 2 voices, and was last updated 7 years, 8 months ago by Ross.
-
Anonymous(Private) February 27, 2017 at 7:26 pm #93288
Just wondering if the meta value sort ordering is working in the latest build? I’m trying to sort by an ACF date but have not had any luck, in fact have not been able to change the sort order at all no matter what settings I use or if I do it on the back end via sf_edit_query_args. I’ve been able to tweak the filtering in other ways, just not the order…
Ross Moderator(Private) February 27, 2017 at 8:11 pm #93336Hey Scott
Is it possible you have a
pre_get_posts
somewhere in your theme, that may be jumping in / hijacking our sort order on the query?Have you tried sf_edit_query_args with a different priority so it runs later, like
2000
?Thanks
Anonymous(Private) February 27, 2017 at 9:10 pm #93355Might have made some progress. When I change the priority I now get no results instead of results in the wrong order. Here’s a code sample:
function filter_sort_by_start_date( $query_args, $sfid ) { if( $sfid==2298 ) { $query_args = array( 'meta_key' => 'class_date', 'orderby' => 'meta_value_num', 'order' => 'DESC' ); } return $query_args; } add_filter( 'sf_edit_query_args', 'filter_sort_by_start_date', 2000, 2 );
I’m getting the “no result” result even if I comment out the other ‘pre_get_posts’ calls.
Ross Moderator(Private) February 28, 2017 at 2:54 pm #93482Ah great stuff.
Did you set it with really low priority to go after other pre_get_posts that were possibly conflicting in your setup?
Ross Moderator(Private) February 28, 2017 at 9:57 pm #93572Good stuff and good to know 🙂
Closing this thread
-
AuthorPosts