Loop posts only 2 months old.
-
Hey guys i have a loop on my sidebar to show 5 random posts. works great but sometimes it can output posts from over a year ago. how would i add a filter so that only posts from up to 2months old will come up?
<?php $tags = wp_get_post_tags($post->ID); if ($tags) { $first_tag = $tags[0]->term_id; } ?> <?php $args = array( 'post_type' => array( 'post', 'review'), 'posts_per_page' => 5, 'post__not_in' => array( $post->ID ), 'tag__in' => array($first_tag) ); $the_query = new WP_Query( $args ); ?> <?php if ( $the_query->have_posts('paged') ) : ?>
Thanks in advance!
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘Loop posts only 2 months old.’ is closed to new replies.