Я использую WordPress 3.5. Мой запрос:
$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();
Это дает точный результат, который я хочу, но,
$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();
Это не работает.
Я немного удивлен, что первый будет работать, потому что это terms
, а не term
. Во всяком случае, правильный способ сделать это:
$args = array( 'post_type' => array('product', 'comic', 'magazine'), 'tax_query' => array( array( 'taxonomy' => 'Genres', 'terms' => array( 'hot', 'home' ), ), 'posts_per_page' => 10 );