WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] pagination not working on custom template (8 posts)

  1. laulief
    Member
    Posted 2 years ago #

    Hello there!

    I'm working on a website were I used selfmade templates. There are some templates on which I include a category. So, the posts are being loaded in a page.

    The problem I have is that no kind of pagination or standard navigation (next & previous post) is working. Not even something like this:

    <?php global $wp_query, $meta ,$paged;
    $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $temp = $wp_query;
    $wp_query= null;
    $wp_query = new WP_Query();
    $wp_query->query("paged=$page&cat=3");
    if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
    while ($wp_query->have_posts()) : $wp_query->the_post();
    ?>
    <?php endwhile ?>
    <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>
    <?php $wp_query = null; $wp_query = $temp; ?>

    [Please post code or markup snippets between backticks or use the code button.]

    Does anybody know how to solve this?

    Thanks in advance!

  2. esmi
    Forum Moderator
    Posted 2 years ago #

    1. There is no post content being displayed via that code.
    2. You have no fallback pagination if WP-PageNavi isn't active.

  3. laulief
    Member
    Posted 2 years ago #

    There's no content being displayed. I see the wp-pagenavi, but when I klik on page 2, I still see the first page, but in the URL is /page/2 added.

  4. esmi
    Forum Moderator
    Posted 2 years ago #

    There's no content being displayed because your code (above) doesn't include anything to display post content.

  5. laulief
    Member
    Posted 2 years ago #

    Well, it's clear I'm not a genius programmer :)

    This is all the code of the template:

    [Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

    I've tried some things, but it won't work.

  6. laulief
    Member
    Posted 2 years ago #

  7. esmi
    Forum Moderator
    Posted 2 years ago #

  8. laulief
    Member
    Posted 2 years ago #

    Got it! Thanks!

    This is the code that works: http://pastebin.com/GHWbb43G

Topic Closed

This topic has been closed to new replies.

About this Topic