adding pagination to custom archives page?
-
I created a custom archives page which currently lists all posts with date/month headers. I would like to limit the number of posts to, say, 50, and add “Next” and “Previous” buttons at the bottom.
Here’s the current code:
<?php // Declare some helper vars $previous_year = $year = 0; $previous_month = $month = 0; $ul_open = false; // Get the posts $myposts = get_posts('numberposts=-1&orderby=post_date&order=DESC'); ?> <?php foreach($myposts as $post) : ?> <?php // Setup the post variables setup_postdata($post); $year = mysql2date('Y', $post->post_date); $month = mysql2date('n', $post->post_date); $day = mysql2date('j', $post->post_date); ?> <?php if($year != $previous_year || $month != $previous_month) : ?> <?php if($ul_open == true) : ?> </ul> <?php endif; ?> <h2 class="pagetitle"><?php the_time('F Y'); ?></h2> <ul id="fullarchive"> <?php $ul_open = true; ?> <?php endif; ?> <?php $previous_year = $year; $previous_month = $month; ?> <li> <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a> </li> <?php endforeach; ?> </ul>
Any ideas how to edit the code? Thanks!
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘adding pagination to custom archives page?’ is closed to new replies.