WordPress.org

Forums

[resolved] Pagination problem (4 posts)

  1. Rakibuzzaman
    Member
    Posted 3 years ago #

    Hi,

    I have been facing pagination problem in category page (WP 3.3) . In wp-admin setting I have set 5 posts per page. Pagination with 5 post page works fine. If I want 2 posts per page and wp-admin setting is 5 posts per page then I get pagination problem.

    Any body please help to solve this problem. And what is wrong in my code.

    Here is my code.

    <?php

    query_posts( "&posts_per_page=2");

    if (have_posts()) :

    while (have_posts()) : the_post(); ?>

    <?php the_content(); ?>

    <?php endwhile; ?>

    <div class="blog_page"><?php previous_posts_link( __( '« New', 'twentyten' ) ); ?>|<?php next_posts_link( __( 'Old »', 'twentyten' ) ); ?></div>

    <?php endif; wp_reset_query(); ?>

  2. alchymyth
    Forum Moderator
    Posted 3 years ago #

    the query needs to have the 'paged' parameter:
    http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters

    try:

    query_posts( "posts_per_page=2&paged=".get_query_var('paged'));
  3. Rakibuzzaman
    Member
    Posted 3 years ago #

    Thanks. I will try.

  4. Rakibuzzaman
    Member
    Posted 3 years ago #

    Yes, it works only if posts_per_page in wp-admin setting less then posts_per_page value in query_posts().

Topic Closed

This topic has been closed to new replies.

About this Topic