0
<?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);


?>
2
  • 1
    Please, add a description of your problem and format the code to be readable.
    – cybmeta
    Commented Dec 9, 2014 at 16:21
  • Your date_query is completely wrong Commented Dec 9, 2014 at 16:55

1 Answer 1

0

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

2
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.