2

I need to create a landing page which only shows posts that are at least a month old.

Everything I've read / tried with the date query so far seems aimed at including posts between the last month and now rather than excluding.. effectively I'm looking to exclude posts between todays date and today-1month.

Any pointers appreciated.

2

The date query for WP_Query supports several options, including before and after. Using just before, you can fetch posts from before a certain date (excluding posts from that date on):

$args = array(
    'date_query' => array(
        array(
            'column' => 'post_date_gmt',
            'before' => '1 month ago'
        )
    ),
    'posts_per_page' => -1,
);

Furthermore, you can specify whether it should be inclusive (date specified is matched as well) or not, using the inclusive key, which defaults to false.

0

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.