WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here is the code in am using

$arg= array(
    'post_type' => 'vr_listing',
    'tax_query' => array(
            'taxonomy' => 'vr_listing_status',
            'field' => 'slug',
            'terms' => array( 'Active', 'Pending','Sold')
    'meta_key' => 'vr_list_price',
    'orderby' => 'meta_value_num',
    'order' => 'DESC'


Each listing has a particular status assigned to it i.e Active,pending,status(different terms in custom taxonomy) What i want to achieve is to first order by price using meta key and at the same time i want to get the results from custom taxonomy from different terms but one by one. e.g first i want to achieve all the results from Active term and then pending and then sold

Any ideas how can i achieve this?

share|improve this question

I think the simplest way would be to run the loop for each status and only output posts that match the current status:

$statuses = array( 'Active', 'Pending', 'Sold' );
foreach( $statuses as $status ):
    echo $status;
    while( have_posts() ):
        if( has_term( $status, 'vr_listing_status' ) ):

A couple of additional notes - if this is the main query, alter it via the pre_get_posts action rather than using query_posts in the template. If this is an additional query and not the main query, use WP_Query.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.