WordPress 3.2 query_posts and pagination, permalinks issue

My question is not new but it just does not work with all found solutions in my case.

I am trying to display recent posts on single post using custom query_posts loop. The permalinks structure must be this one: /%category%/%postname%/

Read More

WordPress version: 3.2.1

The page has 2 loops:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <!--first content part-->
<?php endwhile; endif;?>

<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts('posts_per_page=3&paged='.$paged);

if (have_posts()) : while (have_posts()) : the_post(); ?>
    <!--recent posts-->
<?php endwhile; endif; wp_reset_query();?>

So calling next page like http://www.domain.com/category/post-one/page/2/
simply strips off /page/2/ and does nothing else.

I am desperate already for looking a working solution and not sure if its possible to fix.

Thank you.

Related posts

Leave a Reply

1 comment

  1. From the WP Codex for WP_Query:

    Show Posts from Current Page

    Display posts from current page:

    $query = new WP_Query( ‘paged=’ . get_query_var( ‘page’ ) );

    Pagination Note: You should set get_query_var( ‘page’ ); if you want your query to work with pagination. Since WordPress 3.0.2, you do get_query_var( ‘page’ ) instead of get_query_var( ‘paged’ ). The pagination parameter ‘paged’ for WP_Query() remains the same.

    Changing the query var from ‘paged’ to ‘page’ will result in the following code:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        <!--first content part-->
    <?php endwhile; endif;?>
    
    <?php
    $paged = (get_query_var('page')) ? get_query_var('page') : 1;
    query_posts('posts_per_page=3&paged='.$paged);
    
    if (have_posts()) : while (have_posts()) : the_post(); ?>
        <!--recent posts-->
    <?php endwhile; endif; wp_reset_query();?>