First you need to use the WP_Query to get those posts. Then you can orderby using the following array
.
// The Query
$args = array(
'cat' => $category->term_id,
'posts_per_page' => -1,
'orderby' => 'meta_value',
'meta_key' => '_bunyad_review_overall',
'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1 ),
);
$the_query = new WP_Query( $args );
// Create an array to store posts ID.
$posts_with_ranks = array();
// The Loop
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
// Your post content goes here
// And also you can push each ID into this this array
array_push( $posts_with_ranks , $post->ID );
}
}
// reset post data
wp_reset_postdata();
Now we have our $posts_with_ranks
with the posts with ranks. Let’s suppose our array looks like this:
$posts_with_ranks = array(1,3,5,10);
Then your second WP_Query should look like this:
// The Query
$args = array(
'cat' => $category->term_id,
'posts_per_page' => -1,
'orderby' => title,
'order' => ASC,
'post__not_in' => $posts_with_ranks, // Exclude posts from the previous WP_Query
'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1),
)
$the_query = new WP_Query( $args );
// Create an array to store posts ID.
$posts_with_ranks = array();
// The Loop
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
// Your post content
array_push( $posts_with_ranks , $post->ID );
}
}
// reset post data
wp_reset_postdata();
So basically you need to know this:
1) Use WP_Query to retrieve your posts with rank.
2) Store those posts into an array using array_push
3) Use a second WP_Query and exclude the posts with rank using post__not_in
.
You can see the full wp_query arguments list.
https://gist.github.com/billerickson/3698476#file-gistfile1-php
This is pretty much a comprehensive reference of this.
http://codex.wordpress.org/Class_Reference/WP_Query
Hope this helps!