Created
February 11, 2017 20:42
-
-
Save hemraj7171/8f815b4cbfbb5ace53d8a4e8458cf5c2 to your computer and use it in GitHub Desktop.
Display last 2 days posts on wordpress
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
//query args | |
$posts_args = array( | |
'posts_per_page' => 3, | |
'date_query' => array( | |
'after' => date('Y-m-d', strtotime('-2 days')) | |
) | |
); | |
$posts = get_posts( $posts_args ); | |
//display posts | |
foreach ( $posts as $post ): setup_postdata( $post ); | |
the_title(); | |
endforeach; | |
wp_reset_postdata(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment