navigate and paginate by month
-
Hi
Is there a way to modify the loop so that a page of posts is limited by the month that is being viewed, regardless of if you are viewing a category listing of posts or just the blog-roll?
I am transferring a static news site with several years of content into a cms so would like to try and maintain the same views as set in the current static site.
I tried to modify the loop with
get_lastpostdate()
but I cannot get the previous/next navigation to show anything else but theget_lastpostdate()
.<?php $lastpost = strtotime(get_lastpostdate()); $lastmonth = date('m', $lastpost); $lastyear = date('Y', $lastpost); $args=array( 'post_type' => 'post', 'post_status' => 'publish', 'year'=>$lastyear, 'monthnum'=>$lastmonth, 'order'=>'DESC', 'posts_per_page' =>50 ); query_posts($args); ?>
The reason I used
get_lastpostdate()
is that there could be instances where there are no posts for a month. I thought that this would at least fix this issue for the initial view.I’m a bit stuck on this so any advice on this would be greatly appreciated.
I do have additional questions, such as how to change the paged url navigation from %category%/page/2 to something like %category%/%month-year%. But I think the pagination is much more critical.
Are there any resources that I should read up on to try and understand this better?
Thanks
- The topic ‘navigate and paginate by month’ is closed to new replies.