Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Can you please let me know why this code is not listing Custom Post Types?

$loop = new WP_Query(
                'post_type' => 'product',
                'tax_query' => array(
                        'taxonomy' => 'genre',
                        'field' => 'name',
                        'terms' => 'ne',
                        'order' => 'ASC',
                'posts_per_page' => 10
if ( $loop->have_posts() ) :
echo '<ul>';
 while ( $loop->have_posts()) : $loop->the_post();
 $custom = get_post_custom($post->ID);
 echo '<li>'.the_title().'</li>';
echo '</ul>';


share|improve this question

1 Answer 1

up vote 2 down vote accepted

If you want to sort the custom post type 'product' by title, please try:

 array( 'post_type'       => 'product',
        'posts_per_page'  => 10, 
        'orderby'         => 'title',
        'order'           => 'ASC',
        'tax_query' => array(
             array( 'taxonomy' => 'genre',
                   'field'     => 'slug',
                   'terms'     => 'ne',

where 'field' can in general be either 'id' or 'slug' (ref). You can check the available orderby input parameters here.

share|improve this answer
Thanks birgre, it is working perfectly now – Behseini May 19 '13 at 15:10

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.