I was wondering if someone can help me with this. I am running multiple loops on a client’s news page and they came back to me saying that they want the loops to only show the past 2 years of posts with the rest being viewable via the archive links.
This is one of the loops on the news page:
<!-- Start the Loop for News. --> <h3>Corporate News</h3> <?php $my_query = new WP_Query('category_name=corporate&posts_per_page=5'); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate = $post->ID; ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endwhile; ?> <br /> <div class="morenews"><a href="<?php bloginfo('home'); ?>/news/corporate/">More from Corporate »</a></div> <!-- End the Loop for Corporate News. -->
As you can see, I’m using “WP_Query” in the loop, and calling the category via “Category_Name”. Can someone please show me how to turn what I have into a loop that will limit the posts to ones posted in the past 2 years? Any help would be greatly appreciated.
Thanks in advance,
- The topic ‘How do you show category posts ONLY from last 2 years?’ is closed to new replies.