• Hi,

    Was unsure of how I implement a pagination or a plugin in which the post preview lists loads the next set of posts once a user scrolls to the apparent end of the page.

    at the moment i have had to extend the limit of the posts shown on the front page http://www.thecypher.co.uk which accommodates all the posts ever posted on the front page

    any help on this ?

    thank you

Viewing 9 replies - 1 through 9 (of 9 total)
  • If your template uses query_posts, you must set the ‘paged’ variable in your query. See this reference:

    http://codex.wordpress.org/Function_Reference/query_posts#Pagination

    Thread Starter zubair04

    (@zubair04)

    ah ok thanks for that, so i would just implement this code (removing the need for category and order by) before the loop begins in loop.php ?

    query_posts( array( ‘category__and’ => array(1,3), ‘posts_per_page’ => 2, ‘orderby’ => ‘title’, ‘order’ => ‘DESC’ ) );

    You must use ‘paged’ in addition to any other parameters your query needs.

    So, if you are currently using the query_posts code that you posted, you would need to set a $paged variable and add it to the query like this:

    $paged = (get_query_var('page')) ? get_query_var('page') : 1;
    query_posts( array( 'category__and' => array(1,3), 'posts_per_page' => 2, 'orderby' => 'title', 'order' => 'DESC', 'paged' => $paged ) );
    Thread Starter zubair04

    (@zubair04)

    thanks for your reply, gonna try this out tomorrow

    Thread Starter zubair04

    (@zubair04)

    Ive installed the plugin WP PageNavi…. but not sure what to do next …

    this is the if statement that starts at the beginning of loop.php, just wondering if anything is wrong with this…

    <?php if ( $wp_query->max_num_pages > 1 ) : ?>
    <div id=”nav-above” class=”navigation”>
    <div class=”nav-previous”><?php next_posts_link( __( ‘<span class=”meta-nav”>←</span> Older posts’, ‘twentyten’ ) ); ?></div>
    <div class=”nav-next”><?php previous_posts_link( __( ‘Newer posts <span class=”meta-nav”>→</span>’, ‘twentyten’ ) ); ?></div>
    </div><!– #nav-above –>
    <?php endif; ?>

    More than likely, the problem is with the query_posts() statement. Post a few lines of code (around 10) that show the query_posts() call at the end.

    Thread Starter zubair04

    (@zubair04)

    is this the query posts statement ?


    <?php /* Display navigation to next/previous pages when applicable */ ?>
    <?php if ( $wp_query->max_num_pages > 1 ) : ?>
    <div id=”nav-below” class=”navigation”>
    <?php wp_pagenavi(); ?>
    </div><!– #nav-below –>
    <?php endif; ?>

    No, it will say ‘query_posts()’ with other things inside the parentheses.

    Thread Starter zubair04

    (@zubair04)

    ah i see, this function doesnt exist in my ‘loop.php’ file :S

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