自最新wp发布以来,有一个“tax\\u query”参数可用:
global $query_string;
$args[\'tax_query\'] = array(
array(
\'taxonomy\' => \'status\'
,\'terms\' => array( \'available\', \'pending\' ) // change to "sold" for 2nd query
,\'field\' => \'slug\'
),
);
$args[\'post_type\'] = \'listing\';
parse_str( $query_string, $args );
$avail_n_pend = query_posts( $args );
if ( $avail_n_pend->have_posts() ) :
while ( $avail_n_pend->have_posts() ) :
$avail_n_pend->the_post();
// show result
the_title();
endwhile;
endif;
// use this for testing:
/*
echo \'<pre>\';
print_r($GLOBALS[\'wp_query\']->tax_query);
echo \'</pre>\';
*/
// rewind for second query
rewind_posts();
// second_query
$args[\'tax_query\'] = array(
array(
\'taxonomy\' => \'status\'
,\'terms\' => array( \'sold\' )
,\'field\' => \'slug\'
),
);
parse_str( $query_string, $args );
$sold = query_posts( $args );
if ( $sold->have_posts() ) :
while ( $sold->have_posts() ) :
$sold->the_post();
// show result
the_title();
endwhile;
endif;