• 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)
  • Thread Starter canon2k9

    (@canon2k9)

    Any help would be appreciated. I have read of SQL quieries with multiple ORDER BY statements, but am unable to edit one to work with WordPress. Further, I am under an impression that an array may work, though cannot forge one to work either. Again, any help would be appreciated.

    Have you found an answer? I′m having a similiar problem.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Orderby nesting’ is closed to new replies.