• Resolved RDStudent

    (@rdstudent)


    Hello,
    I am wondering if someone can help me out. I have a custom-page-template that uses this query:

    <?php // The Query
          query_posts( array ('category_name' => 'for-sale', 'posts_per_page' => 2) ); ?>

    And these controlls

    <?php global $wp_query;
           if($wp_query->max_num_pages > 1) :?>
    
    <?php previous_posts_link('&larr; Previus Page', $wp_query->max_num_pages);?>
    <?php next_posts_link('Next Page &rarr;', $wp_query->max_num_pages);?>

    Issue I am getting is that, Next and Prev works fine. I always get correct number of pages and all but my content always stays the same.

    I figured issue is every time the page reloads on Next and Prev, query runs and gets first X number of items.

    I am wondering how I can do this and if this is even possible to do:
    I am thinking to create a global control variable X like +1 -1, that will be incremented and decremented by Next and Prev buttons.

    Now when the page loads I would say wp_guery(indexOf X).

    Is this possible ?

Viewing 2 replies - 1 through 2 (of 2 total)
  • There is a paged/page parameter you can add to your query:

    if( get_query_var( 'paged' ) ) {
    
      $paged = get_query_var( 'paged' );
    
    }
    elseif( get_query_var( 'page' ) ) {
    
      $paged = get_query_var( 'page' );
    
    }
    else {
    
      $paged = 1;
    
    }
    
    query_posts( array ('category_name' => 'for-sale', 'posts_per_page' => 2, 'paged' => $paged ) );
    ...

    (http://codex.wordpress.org/Pagination#static_front_page)

    Thread Starter RDStudent

    (@rdstudent)

    OMG … I already found this but I forgot to add the ‘category_name’ => ‘for-sale’ part to the new query… OMG Im such a donkey!!

    Thank you so so sooooo much Chris!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Page Navigation Next Prev’ is closed to new replies.