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


?>
  • 1
    Please, add a description of your problem and format the code to be readable. – cybmeta Dec 9 '14 at 16:21
  • Your date_query is completely wrong – Pieter Goosen Dec 9 '14 at 16:55
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

  • Please add an explanation to how your code works and how it should be used – Pieter Goosen Dec 9 '14 at 16:23
  • Sure, @PieterGoosen - is that sufficient to explain OP's issue? – skim- Dec 9 '14 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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