Orderby nesting
-
Here is the situation. I have posts that I would like sorted in their respective categories. I can get the posts to sort once using the orderby statement, however, need to sort even further.
For example. year, month, and selection number.
add_action('pre_get_posts','sort_categories_by_title'); function sort_categories_by_title($x) { if(is_category()) { $x->query_vars['orderby'] = 'meta_value'; $x->query_vars['meta_key'] = 'selection-no'; $x->query_vars['meta_key'] = 'release-month'; $x->query_vars['meta_key'] = 'release-year'; $x->query_vars['order'] = 'asc'; } }
The result is a single sort by the last item in the list, release-year. I have tried all I could but with no success. Any help would be appreciated.
Incidentally, this code is adapted from a plugin available https://www.mikesmullin.com.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Orderby nesting’ is closed to new replies.