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 have created a custom post type to display churches in Europe. I used this tutorial to make it filterable: http://wp.tutsplus.com/tutorials/creating-a-filterable-portfolio-with-wordpress-and-jquery/

Everything on my site works as normal: http://globalicn.com/preview/regions/europe/

My question is, I would like the posts to be organized by the Country not the post of the title.

<?php
$loop = new WP_Query(array('post_type' => 'europe', 'posts_per_page' => -1, 'orderby' =>         'title', 'order' => 'asc'));
$count =0;
?>

What can I do?

share|improve this question

1 Answer 1

I am assuming that 'country' is a custom meta field. In that case, you need this (very much like one of the examples in the Codex):

$loop = new WP_Query( 
    array ( 
        'post_type' => 'europe', 
        'posts_per_page' => -1,
        'orderby' => 'meta_value', 
        'meta_key' => 'country' 
        'order' => 'asc'
    ) 
);
share|improve this answer

Your Answer

 
discard

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.