Pagination stays on the same page (4 posts)

  1. ivanasetiawan
    Posted 5 years ago #

    I am using WP Page Numbers plugin to show pagination. Problem is when I click 'next' - the page seems to load on the same page. I understand that the issue came from query_posts but I am not sure how to fix it.

    This is the code that I am using atm:

    <?php query_posts('category_name=notes_blog&showposts=3'); ?>
                <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                        <div class="post_wrapper">
                        <article <?php post_class() ?> id="post-<?php the_ID(); ?>">
                                <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to
                                <?php the_title_attribute(); ?>"><?php the_title(); ?>
                            <div class="post_content">
                                <?php the_excerpt();?>
                        <!-- Can always include comment later on // commentform styled under layout.css -->
                            <aside class="aside_option">
                                <ul class="published">
                                    <li><?php the_time('F jS, Y') ?></li>
                                    <li>posted at <?php the_time() ?></li>
                                    <li><span class="italic">by</span> <?php the_author(); ?></li>
                        </div> <!-- whole post & share (post_wrapper) -->
                    <?php endwhile; ?>
                    <?php if (show_posts_nav()) : ?>
                    <?php if(function_exists('wp_page_numbers')) { wp_page_numbers(); } ?>
                    <?php endif; ?>
                    <?php else : ?>
                            <h2>Not Found</h2>
                            <p>Sorry, but you are looking for something that isn't here.</p>
                            <?php get_search_form(); ?>
                    <?php endif; ?>

    Live version available here

    Thanks alot - I really appreciate it!

  2. Michael
    Part-Time Forum Moderator
    Posted 5 years ago #

    try to add the 'paged' parameter to the query, together with $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

    so your first lines look like:

    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
    <?php query_posts('category_name=notes_blog&showposts=3&paged=' . $paged); ?>
                <?php if (have_posts()) : while (have_posts()) : the_post(); ?>


  3. ivanasetiawan
    Posted 5 years ago #

    OMG!!! I LOVE YOU! :D

    Thanks <3

  4. ivanasetiawan
    Posted 5 years ago #

    Can you please explain briefly what cause the problem?

Topic Closed

This topic has been closed to new replies.

About this Topic