• Hi everyone
    I am using a Mimbo Theme. On the homepage i have that:

    <?php if (have_posts()) { ?>
    
    <div id="content">
    
     <?php
    	$postCount = 0;
    	$page = (get_query_var('paged')) ? get_query_var('paged') : 0;
    	query_posts( 'paged=$page&amp;post_per_page=-1&amp;cat=' . get_query_var('cat') );
    	while (have_posts()) { the_post();
    		if( $postcount == 0 ) {
    		//GETS LATEST OR STICKY POST
    	?>
    
    <div id="box" style="width:182px; background: #D8D8D8; float: right; margin-top:22px; height:258px;"></div>
    
        <div id="lead" class="clearfloat">
    
    	<div id="lead-text">
        <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>">
        <?php the_title(); ?></a> <span class="commentcount"> (<?php comments_popup_link('0', '1', '%'); ?>)</span></h2>
    
        <p class="date"><?php the_time('n/d/y'); ?> &bull; </p>
    	<?php the_excerpt(); ?>
    	</div>
    			</div><!--END LEAD/STICKY POST-->
    
    		<div id="more-posts">
    		<h3><?php _e('Recent Posts','Mimbo'); ?></h3>
    
    		<?php
    		}
    		elseif($post) {
    		//GETS NEXT FOUR EXCERPTS
    		?>
    
    		<div class="clearfloat recent-excerpts">
    
    <h4><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a> <span class="commentcount">(<?php comments_popup_link('0', '1', '%'); ?>)</span></h4>
    
    <p class="date"><?php the_time('n/d/y'); ?> &bull; </p>
    
        <?php the_content(); ?>
    
            </div>
    
    <?php //GETS NEXT HEADLINES
    		}
    		else {
    			ob_start();
    			echo '<li><a href="';
    			the_permalink();
    			echo '">';
    			the_title();
    			echo '</a></li>';
    			$links[] = ob_get_contents();
    			ob_end_clean();
    		}
    		$postcount ++;
    		}
    	}
    	else {
    ?>
    
    <?php } ?>
    	 <div id="nav-links">
    <div id="next">
        <?php next_posts_link('Next &raquo;') ?>
    </div>
    <div id="prev">
        <?php previous_posts_link('&laquo; Previous') ?>
    </div>
    </div>
    
    <?php
    	if(count($links)): ?>
    
    	<?php endif; ?>
    	</div>

    And links for previuos and next posts doesn’t work. Any idea?
    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • This code is incorrect

    $page = (get_query_var('paged')) ? get_query_var('paged') : 0;

    Its supposed to be
    $page = (get_query_var('paged')) ? get_query_var('paged') : 1;

    Also, in your query_posts… This forum turns an ampersand into & a m p ; (no spaces) Its supposed to be just ampersand not that full code.

    There may be other issues but that one stood out

    Hi,

    For correct details Refer this:

    http://codex.wordpress.org/Next_and_Previous_Links

    Thanks,

    Shane G.

    Thread Starter sergis

    (@sergiselvas)

    Hi, thanks for your help, but it still doesn’t work.
    I changed to that

    $page = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;

    And I add

    <div class=”navigation”><p><?php posts_nav_link(); ?></p></div>

    You can see my site at http://wwww.sergiselvas.com/blog Could any one take a look? I’m quite new on this and I need some help

    Thanks everyone!

    This code

    $postCount = 0;
    	$page = (get_query_var('paged')) ? get_query_var('paged') : 0;
    	query_posts( 'paged=$page&amp;post_per_page=-1&amp;cat=' . get_query_var('cat') );

    must be before this line
    <?php if (have_posts()) { ?>

    the if_posts() has to refer to the custom query you are running, thus must be preceded by it.
    I believe this $postCount = 0; is not only not necessary but may also be part of the paging problems. $postCount is set as part of the query that is run and is not manually reset

    Thread Starter sergis

    (@sergiselvas)

    It works! Thanks alot!

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

The topic ‘“Next & previous” doesn’t work!’ is closed to new replies.