Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm wondering if it's possible in one loop to accomplish what I need to do. What I would like is to sort all custom post types by the meta data of county and put them in order which it is doing here. But I would also like it to then sort by acres within that. So it would look like:

County 1 - acres 1, County 1 - acres 2, County 2 - acres 1, County 2 - acres 2 etc.

But I have a third meta data value that I would like to sort by also. So I would like it to behave this way but show the properties that are not sold first and then the ones that are sold second.

So it would look like:

County 1 - acres 1 - not sold, County 1 - acres 2 - not sold, County 2 - acres 1 - not sold, County 2 - acres 2 - not sold, County 1 - acres 1 - sold, County 1 - acres 2 - sold, County 2 - acres 1 - sold, County 2 - acres 2 - sold etc.

Is this possible?

Thanks in advance!

               <?php $args = array( 
                    'post_type' => 'property', 
                    'posts_per_page' => 100, 
                    'orderby' => 'meta_value', 
                    'meta_key' => 'county', 
                    'order' => 'ASC'
                    );


                    $loop = new WP_Query( $args );
share|improve this question
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.