• Here is my simple problem. I am trying to get the previous page and next page function to work with this code, but they do nothing.

    I have a category named news with just five entries in it for now and the top two entries display perfectly, but when I click on next page and previous page the entries do not change at all.

    Do I need to go a different route with the code to get what I want??

    <?php query_posts('category_name=news&showposts=2'); ?>
    <?php while (have_posts()) : the_post(); ?>  
    
    <div class="storycontent" align="left">
    		<?php the_content(__('(more...)')); ?>
    	</div>
    <!-- Do special_cat stuff... -->
    
    <?php endwhile; ?>
    
    <?php posts_nav_link(' — ', __('&laquo; Previous Page'), __('Next Page &raquo;')); ?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • Try changing:
    <?php query_posts('category_name=news&showposts=2'); ?>
    to

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array(
    	'category_name' => 'news',
    	'posts_per_page => 2,
    	'paged' => $paged
    );
    query_posts($args);
    ?>

    Thread Starter richardginn

    (@richardginn)

    Well I tried the code out you gave me and it listed all five entries on the page and for now I needed only two and then the next page and previous page stuff did not show up at all.

    Thread Starter richardginn

    (@richardginn)

    i looked at the page of post code

    https://codex.www.ads-software.com/Pages

    but even in that code if it is right i do not where to put this code and get it to show up.

    <?php posts_nav_link(' — ', __('&laquo; Previous Page'), __('Next Page &raquo;')); ?>

    this is what i use

    <!-- blog_navigation -->
    <div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
    <div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
    <!-- /blog_navigation -->
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Need Help with some code….’ is closed to new replies.