+1 (also looking for sorting through an advanced custom field)
For those who wanna know how to Query Posts and set a orderby->meta_value: http://codecanyon.net/item/quick-ajax-modern-wordpress-ajax-query-posts/5740469
This premium plugin is my solution. In fact it isnt that powerfull like query wrangler but you can sort by a custom field meta value with a special Shortcode – works great for me.
Add this to your functions.php
// Custom sort by rating
function my_custom_sort( $query ) {
if ( $query->is_archive())
{
$query->set('meta_key', 'rating');
$query->set('orderby', 'meta_value_num');
$query->set('order', 'ASC');
}
return $query;
}
add_action('pre_get_posts', 'my_custom_sort');
Hi All,
In the most recent update (1.5.31) I’ve added 2 new sort options. Meta Value – for text, and Meta Value Number – for numbers.
They require you also add a “Meta Key” filter with the appropriate sorting key.
Using the rating system as an example:
1. Add a new Meta Key filter, set key to “rating” without quotes
2. Add a Meta Value Number sort, set to ASC/DESC
Hope this helps, and thanks Riaan for the help!
Jonathan
Nice one Johnathan!
The code I have posted is a overriding WP function and will force all queries to sort that way, if they have the rating value. Not very flexible.
This way we have control. Good work. I will definitely be using this functionality.
Riaan