<?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);
?>
1 Answer
When you set up your query, do it this way ( I believe you were missing the 'date_query' key ):
$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
-
Please add an explanation to how your code works and how it should be used Commented Dec 9, 2014 at 16:23
-
Sure, @PieterGoosen - is that sufficient to explain OP's issue?– skim-Commented Dec 9, 2014 at 16:23
date_query
is completely wrong