<?php
$lastThirty = date(\'Y-m-d\', strtotime(\'today - 30 days\'));
$currentMonth = date(\'M Y\');
$t = date(\'d-m-Y\');
$today = date("D",strtotime($t));
$lastThirty = array(
\'date_query\' => array(
\'post__not_in\' => get_option( \'sticky_posts\' ),
\'ignore_sticky_posts\' => false,
array(
\'year\' => $lastThirty,
\'month\' => $currentMonth,
\'day\' => $today,
\'orderby\' => \'date\',
\'order\' => \'DESC\'
),
),
); ?>
<?php
$the_query = new WP_Query($lastThirty);
?>
SO网友:skim-
设置查询时,请这样做(我认为您缺少“date\\u query”键):
$args = array(
\'date_query\' => array(
array(
\'year\' => 2012,
\'month\' => 12,
\'day\' => 12,
),
),
\'ignore_sticky_posts\' => true,
\'post__not_in\' => get_option(\'sticky_posts\') ...
);
$query = new WP_Query( $args );
http://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters