There is a plugin that I am trying to adapt for my meta_tags for use with WordPress. It is called Categories by Title by http://www.mikesmullin.com.
What I am trying to achieve is a nested sort. I have three meta_keys. A selection-no, release-month, and release-year. I would like to sort posts within their category by release-year (asc), release-month (asc), then selection-no (asc). For example: 1955 10 selection-no-1, 1956 10 selection-no-2, 1956 10 selection-no-5, and so on.
I have modified the code, however, it only sorts by the last meta_key listed, by release-year.
Here is the code.
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';
}
}
Any help would be greatly appreciated. Thank you.