• I can’t figure out why the pagination isn’t working, I tried WP-Navi and it’s still not working (using blogressive theme), when i go to page 2 the same four latest posts only show and not the newer post code below:

    ?php
    
    $wp_query = new WP_Query();
    $wp_query->query('cat=-5&showposts=4'.'&paged='.$paged);
    ?>
    
    <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
    <img src="<?php bloginfo('url'); ?>/img/top_icon_report.gif" width="95" height="22" border="0" class="report" />	
    
    <div class="post-home">
    <div class="postThumb"><a href="<?php the_permalink() ?>"><?php the_post_thumbnail(); ?></a></div>
    <div class="date"><?php echo date("F d, Y"); ?></div>
    
    <img src="http://image/top_line01.gif" border="0"  class="line" />
    
    <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>">
    
    <?php the_title(); ?></a></br>
    
    <?php $excerpt = get_the_excerpt();
    echo string_limit_words($excerpt,35); ?>
    </div>
    
    <?php endwhile; ?>
    
    <? next_posts_link('← Older Entries') ?>
    <? previous_posts_link('Newer Entries →') ?>
Viewing 11 replies - 1 through 11 (of 11 total)
  • You do not have a $paged variable. Try:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $wp_query = new WP_Query();
    $wp_query->query('cat=-5&showposts=4'.'&paged='.$paged);
    ?>
    Thread Starter kaformedia

    (@kaformedia)

    still not working can there be anything else? can you check blogressive theme?

    There are literally thousands of WordPress themes – which means that many people won’t be familiar with your particular theme. So a link to your site where people can see the theme might result in more responses.

    Try query_posts instead of wp_query as following:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array(
      'cat' => 5,
      'posts_per_page' => 4,
      'paged' => $paged
    );
    query_posts( $args );
    if ( have_posts() ) {
     while ( have_posts() ) {
      the_post();
      // post content
     }
     // Paging code
    }

    Thread Starter kaformedia

    (@kaformedia)

    get this error: Parse error: syntax error, unexpected T_STRING
    with above code

    Remove If condition from my code, write as follows:

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array(
      'cat' => 5,
      'posts_per_page' => 4,
      'paged' => $paged
    );
    query_posts( $args );
    while ( have_posts() ) : the_post();
     //Post Content
    endwhile;
    
    // Paging
    next_posts_link('← Older Entries');
    previous_posts_link('Newer Entries →');
    ?>

    Thread Starter kaformedia

    (@kaformedia)

    sorry it was a div missing, fixed thank you for the code from both.

    Great!

    Please mark the issue as resolved.

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array(
      'cat' => 5,
      'posts_per_page' => 4,
      'paged' => $paged
    );
    query_posts( $args );
    while ( have_posts() ) : the_post();
     //Post Content
    endwhile;
    
    // Paging
    next_posts_link('← Older Entries');
    previous_posts_link('Newer Entries →');
    ?>

    to get the code working for me, I first have to change the first row with

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

    to

    <?php
    $paged = (get_query_var('page')) ? get_query_var('page') : 1;

    (the term paged changed to page) and this seems to be legit referring to this last comment on Pagination Parameter saying:

    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.

    haven’t seen anyone highlighting this when discussion the same problem, are many people using elder versions of WP or what?

    Moderator keesiemeijer

    (@keesiemeijer)

    @haselovic

    haven’t seen anyone highlighting this when discussion the same problem, are many people using elder versions of WP or what?

    I think the codex is wrong there.

    I think you should use get_query_var('page') on a single Post or Page (template) that has been divided into pages using the <!–nextpage–> QuickTag.
    And also on a static front page (template) that has a query on the loop. On all other template files you should use “paged”.

    Did you change it to “page” on a static front page (page template)?
    If not, on what theme template file did you have to change it to “page”?

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Pagination, need help ASAP’ is closed to new replies.