WordPress.org

Ready to get started?Download WordPress

Forums

Adding Pagination to Custom Template (1 post)

  1. justbishop
    Member
    Posted 3 years ago #

    I have a custom template I'm using on a page to display pending posts, and am at a total loss as to how to add pagination. I tried doing some c&p from my theme's (Blix) archive.php, but the code calling the posts themselves is way different than what I'm using on my custom template, and the pagination code from archive.php just isn't working.

    Here's the code I have on my custom template, all except the header, sidebar, and footer adding codes. I did try adding numberposts=n to my get_posts query, but that obviously did nothing to add the "next page" and "previous page" links that I'm wanting:

    <?php
     $latest = get_posts('post_status=pending');
     foreach($latest as $post) :
        setup_postdata($post);
     ?>
    
    [Loop stuff here, snipped for posting in support]
    
     <?php endforeach; ?>

    And here's my archive.php code, including the working next/previous links:

    <?php get_header(); ?>
    
                <div id="content" class="column archive">
    
    <?php if (have_posts()) : ?>
    
                    <?php /* If this is a category archive */ if (is_category()) { ?>
                    <h2><?php _e('Filed under:'); echo ' ', single_cat_title(); ?></h2>
    
                    [etc., snipped for posting in support]
    
                    <?php } ?>
    
        <?php while (have_posts()) : the_post(); ?>
    
    	<?php $custom_fields = get_post_custom(); ?>
    
    	<?php if (isset($custom_fields['BX_post_type']) && $custom_fields['BX_post_type'][0] == 'mini') { ?>
    
            <?php } else { ?>
    
                    <div class="entry">
    
                    [Loop stuff here, snipped for posting in support]
    
                    </div>
    
    <!--
    <?php trackback_rdf(); ?>
    -->
    
            <?php } ?>
    
        <?php endwhile; ?>
    
                    <p>
                        <span class="next"><?php previous_posts_link(__('Next page')) ?></span>
                        <span class="previous"><?php next_posts_link(__('Previous page')) ?></span>
                    </p>
    
    <?php else : ?>
    
                    <h2><?php _e('Page not found'); ?></h2>
                    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    
    <?php endif; ?>
    
                </div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    Can someone please help me understand how to make this work?

Topic Closed

This topic has been closed to new replies.

About this Topic