WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Paging displays 1 extra page that is empty (7 posts)

  1. gregnak
    Member
    Posted 4 years ago #

    Hi everyone!
    I've been searching for hours but could find any soloution to my problem.

    I have a template-file that lists all the posts from the category "blogg"
    What i want to do is show the first 10 posts, then use next_posts_link to go to page 2 etc etc.
    Edit:
    And if it's less then 10 posts, it still displays navigation, and ads 2 extra pages, thats empty.

    It works, exept for one thing. When i've clicked through the pages, i get one last page thats empty. Any ideas? Heres the code:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $get_blog = new WP_Query('category_name=blogg&posts_per_page=10&paged=' . $paged);?>
    <?php while ($get_blog->have_posts()) : $get_blog->the_post();
    if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>

    And the navigation:

    <?php previous_posts_link('&laquo; Nyare') ?>
    <?php next_posts_link(' Äldre &raquo;') ?>

    Thanks in advanced!

  2. MichaelH
    Member
    Posted 4 years ago #

    What happens if you delete this:

    if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts);
  3. gregnak
    Member
    Posted 4 years ago #

    Same result.
    You can view what happens here:
    http://celebrationstudios.se/blogg/

  4. MichaelH
    Member
    Posted 4 years ago #

    Please paste all the code from the theme template file (probably index.php) that is displaying those posts into a pastebin such as wordpress.pastebin.com, and report the link back here. Maybe someone can spot your problem. Thanks.

  5. gregnak
    Member
    Posted 4 years ago #

    http://wordpress.pastebin.com/e50rSsfe
    Hope that helps!
    Oh, and thanks for taking time to help MichaelH

  6. MichaelH
    Member
    Posted 4 years ago #

  7. gregnak
    Member
    Posted 4 years ago #

    That sure worked! Great!
    Thanks everyone!

Topic Closed

This topic has been closed to new replies.

About this Topic