• Hi,

    On a page that I am developing (http://www.oxfordrescue.org/wp/adopt-a-ferret/available-ferrets/) I can’t figure out how to get the Next and Previous pagination links to work.

    I’ve created my own template for this page. The top of the page is pulling in page content using the loop. Then, below that, I am using the following code to pull in posts from one specific category:

    $postslist = get_posts('numberposts=10&order=DESC&category=5&orderby=date');
     foreach ($postslist as $post) :
        setup_postdata($post);

    It works great, I love the result, but unfortunately, standard pagination using next_posts_link and previous_posts_link does not work (nothing shows up at all). And I do definitely need pagination for this page.

    I’d be grateful for any suggestions – let me know if I can provide any more details that will be helpful.

    Kym

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi

    try using a wp_query loop instead of get_posts
    http://weblogtoolscollection.com/archives/2008/04/13/define-your-own-wordpress-loop-using-wp_query/

    Also you will need this paging code in conjunction with the query statement

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $postlists = new WP_Query();
    $postlists->query("paged=$paged&showposts=10&order=DESC&category=5&orderby=date');
    while ($postlists->have_posts()) : $postlists->the_post(); ?>
      ==== do stuff ========
    <?php endwhile; ?>

    Information about getting post_nav_link to work is at the bottom of that article linked to above.

    Thread Starter the_webscaper

    (@the_webscaper)

    Aha – okay, making progress here!

    I got stvwlf’s solution to work, and with a little tweaking it’s doing ALMOST what I want it to do! Thank you so much!

    The one little nitpicky thing though is… now, the Previous and Next links are there, no matter what – even if there isn’t a “Next” or “Previous” post.

    View this page: http://talk.girlsplan.org/blog/

    and you’ll see there’s a “Next Entry” link, but since this page shows the most recent post, there wouldn’t be a “next.” If you click it, it shows a blank page. It’s not the end of the world, but my guess is my client will bring it up.

    Is there a way to make that not happen?

    Thanks again so much for your help! and Shane, thank you for your reply too… I didn’t try the plugin, was hoping to avoid using a plugin solution, but if this can’t work, that’s next on my list to try…

    Kym

    Thread Starter the_webscaper

    (@the_webscaper)

    Oops, slight modification to my previous post. There isn’t a NEXT link on the most recent post; but I do get PREVIOUS links on the oldest post.

    So if you go here: http://talk.girlsplan.org/blog/, hit previous, then hit previous again – you’ll be on the oldest post (there are only three). But the PREVIOUS link is still there, and if you click it, then I get the blank page.

    Any suggestions welcome – thank you!

    Kym

    I have a problem with pagination too. Page 2 and above shows me a blank post. Page 1 is displaying correct posts.
    Here is the link: http://gadgetforest.com
    Can anyone please give me a hint?

    having a similar issue, except when I hit the next link it displays the same posts again

    here is the code I’m using:

    <?php
                            $thequery = new WP_Query();
                    	$thequery->query('category_name=featured'.'&paged='.$paged);
                    ?>
    
                    <?php if($thequery->have_posts()) : while ($thequery->have_posts()) : $thequery->the_post(); ?>
    
    =====do stuff======
    <?php endwhile; ?>
    <?php endif; ?>

    I tried inserting the following:
    <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;

    but this didn’t seem to make a difference.

    Anyone have any ideas?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Pagination problem – stumped’ is closed to new replies.