I've been using the Wp_query command for a while, to create my own custom loops, but I'm not sure how to proceed with my current problem.
I first want to sort on title name, this is easy... see arg's below.
$args = array( 'showposts' => -1, 'orderby' => 'title', 'cat' => get_post_meta($this_post_id, "course_category_id", true), 'category__not_in' => get_post_meta(getSettingsPageID(), "demonstration_category_id", true), 'order' => 'ASC' ); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query($args);
Within the same query I then want to sort on a custom field... this by itself I can also do as:
$args2 = array( 'showposts' => -1, 'meta_compare' => '>=', 'meta_key' => 'date', 'meta_value' => date("Ymd"), 'orderby' => 'meta_value', 'order' => 'ASC' 'category__and' => array(get_post_meta($this_post_id, "course_category_id", true), get_post_meta(getSettingsPageID(), "demonstration_category_id", true)) );
but I'd like to be able to do both of these queries in a single call.
get posts in category X
sort by title
sort all posts with the same title by custom field
The only way I can think to do it at the moment is to get all the titles, then for each title do a seperate query sorted on date. There must be a better way!
Any help gratefully recieved.