如上所述here, 您可以向查询中添加其他筛选器。
// Create a new filtering function that will add our where clause to the query
function filter_where( $where = \'\' ) {
$where .= " AND DATE(post_date) >= DATE(NOW())";
return $where;
}
add_filter( \'posts_where\', \'filter_where\' );
$query = new WP_Query( $query_string );
remove_filter( \'posts_where\', \'filter_where\' );
在您的情况下,这意味着:
<?php
// Create a new filtering function that will add our where clause to the query
function filter_where( $where = \'\' ) {
$where .= " AND DATE(post_date) >= DATE(NOW())";
return $where;
}
add_filter( \'posts_where\', \'filter_where\' );
$portfolioloop = new WP_Query(array(
\'paged\' => get_query_var(\'paged\'),
\'post_type\' => \'news\',
\'posts_per_page\' => 4,
\'tax_query\' => array(
array(
\'taxonomy\' => \'news\',
\'field\' => \'id\',
\'terms\' => 51,
),
),
));
remove_filter( \'posts_where\', \'filter_where\' );
?>