Custom post query by taxonomy

I am using WordPress 3.5. My query is,

$args = array(
    'post_type' => array('product', 'comic', 'magazine'),
    'taxonomy' => 'Genres',
    'term' => 'hot',
    'posts_per_page' => 10
);
$the_query = new WP_Query( $args );

// The Loop
while ( $the_query->have_posts() ) :
    $the_query->the_post();
    echo '<li>' . get_the_title() . '</li>';
endwhile;

// Restore original Query & Post Data
wp_reset_query();
wp_reset_postdata();

This gives the exact result that I want but,

Read More
$args = array(
    'post_type' => array('product', 'comic', 'magazine'),
    'taxonomy' => 'Genres',
    'term' => array('hot','home'),
    'posts_per_page' => 10
);
$the_query = new WP_Query( $args );

// The Loop
while ( $the_query->have_posts() ) :
    $the_query->the_post();
    echo '<li>' . get_the_title() . '</li>';
endwhile;

// Restore original Query & Post Data
wp_reset_query();
wp_reset_postdata();

This is not working.

Related posts

Leave a Reply

1 comment

  1. I’m slightly surprised that the first would work, because it’s terms, not term. Anyway, the correct way to do this is:

    $args = array(
        'post_type' => array('product', 'comic', 'magazine'),
        'tax_query' => array(
         array(
            'taxonomy' => 'Genres',
            'terms'    => array( 'hot', 'home' ),
            ),
        'posts_per_page' => 10
    );