Quantcast
Channel: WordPress.org Forums » All Posts
Viewing all articles
Browse latest Browse all 112486

vtxyzzy on "Sorting second level of custom fields"

$
0
0

You will need to use a filter to alter the sort order.

Try adding these lines before your $args setting:

function mam_posts_orderby ($orderby) {
   global $mam_global_orderby;
   if ($mam_global_orderby) $orderby = $mam_global_orderby;
   return $orderby;
}
add_filter('posts_orderby','mam_posts_orderby');
$mam_global_orderby = "$wpdb->postmeta.meta_value ASC, $wpdb->posts.post_title ASC";

Then add this line after the query_posts() to clear the filter:

$mam_global_orderby = '';

Viewing all articles
Browse latest Browse all 112486

Trending Articles