Last active
August 29, 2015 14:22
-
-
Save hirejordansmith/92f66a198fdef579ad5c to your computer and use it in GitHub Desktop.
How to get posts published in the last 30 days using WP_Query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$paged = get_query_var('paged') ? get_query_var('paged') : 1; | |
$args = array( | |
'post_type' => 'post', | |
'order'=>'DESC', | |
'posts_per_page' => 12, | |
'date_query' => array( | |
array( | |
'after' => '-30 days', | |
'column' => 'post_date', | |
), | |
), | |
'paged' => $paged | |
); | |
$loop = new WP_Query( $args ); | |
while ( $loop->have_posts() ) : $loop->the_post(); | |
// LOOP CONTENT HERE | |
endwhile; | |
?> | |
<?php wp_pagenavi( array( 'query' => $loop ) ); ?> | |
<?php | |
wp_reset_query(); | |
wp_reset_postdata(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment