• Resolved englishcoder

    (@englishcoder)


    Hi all,

    I’m working on a theme which features a gallery (posts) which works fine on page 1. I’m using the PageNavi plugin which shows 3 pages and has links to each one but the content is the latest (page 1’s) posts.

    Can anyone point out where I’m going wrong?

    The page is here.

    The query I’m running is:

    <?php query_posts('orderby=desc&paged=$paged') ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    	<div class="entry grid_3">
    
    		<div class="gallery-image">
    			<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php postimage(158,160); ?></a>
                	</div><!-- /gallery-image -->
    
    		<div class="gallery-vote">
    			<?php if(function_exists('the_ratings')) { the_ratings(); } ?>
                	</div><!-- /gallery-vote -->
    
    	</div><!-- /entry -->
    
        <?php endwhile; endif;?>

    Any help would be greatly appreciated!

    Many thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Try this before your query_posts line:

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

    Thread Starter englishcoder

    (@englishcoder)

    Thanks for the quick reply.

    I’ve tried the code but it hasn’t had any effect. Does it make a difference that this is a page template rather than an archive page?

    Any other suggestions?

    Many thanks.

    I’ve not been able to get paging working properly in a page template…maybe someone else has…

    Thread Starter englishcoder

    (@englishcoder)

    Got it working by using this code:

    <?php
    		$temp = $wp_query;
    		$wp_query= null;
    		$wp_query = new WP_Query();
    		$wp_query->query('showposts=5'.'&paged='.$paged);
    	?>
    
    	<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
    
    		<div class="entry grid_3">
    
    			<div class="gallery-image">
    				<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php postimage(158,160); ?></a>
                </div><!-- /gallery-image -->
    
                <div class="gallery-vote">
    				<?php if(function_exists('the_ratings')) { the_ratings(); } ?>
                </div><!-- /gallery-vote -->
    
    		</div><!-- /entry -->
    
        <?php endwhile; ?>
    
        <br class="clear" />
    
        <?php if (function_exists('wp_pagenavi')) { ?>
        <div id="pagenavi-wrap">
        	<?php  wp_pagenavi(); ?>
        </div>
        <?php } ?>
    
        <?php $wp_query = null; $wp_query = $temp;?>

    Awesome, Englishcoder, that’s what I was just looking for.

    For me, it was enough to use

    $wp_query->query('cat=26'.'&paged='.$paged);

    and none of the other stuff.

    I am having the same problem. If you click on any of our categories only the first page shows although it shows multiple pages exist. The second page will show no results….

    the site, which just launched live last night, is http://www.AbandonedOK.com

    the code from my index page is as follows….

    <?php if (is_archive()) $post_number = get_option('abandonedok2_archivenum_posts');
    if (is_search()) $post_number = get_option('abandonedok2_searchnum_posts');
    if (is_tag()) $post_number = get_option('abandonedok2_tagnum_posts');
    if (is_category()) $post_number = get_option('abandonedok2_catnum_posts');
    if (is_home()) $args=array(
    					   'showposts'=>get_option('abandonedok2_homepage_posts'),
    					   'paged'=>$paged,
    					   'category__not_in' => get_option('abandonedok2_exlcats_recent'),
    					); ?>
    <?php get_header(); ?>
    
    <?php global $query_string;
    if (is_category()) query_posts($query_string . "&showposts=$post_number&paged=$paged&cat=$cat");
    elseif (is_home()) query_posts($args);
    else query_posts($query_string . "&showposts=$post_number&paged=$paged"); ?>
    
    <div id="main-content-wrap">
    	<div id="main-content" class="clearfix">
    		<?php include(TEMPLATEPATH . '/includes/breadcrumb.php'); ?>
    		<div id="top-shadow"></div>
    
    		<div id="recent-posts" class="clearfix">
    			<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    				<?php include(TEMPLATEPATH . '/includes/entry2.php'); ?>
    			<?php endwhile; ?>
    
    				<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
    					else { ?>
    						<?php include(TEMPLATEPATH . '/includes/navigation.php'); ?>
    				<?php } ?>
    
    			<?php else : ?>
    				<?php include(TEMPLATEPATH . '/includes/no-results.php'); ?>
    			<?php endif; wp_reset_query(); ?>		
    
    		</div> <!-- end #recent-posts -->
    
    		<?php get_sidebar(); ?>
    
    <?php get_footer(); ?>

    I have tried several suggestions from .org and can’t seem to get any of them working. Thanks for any help!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Paged (page 2 etc) not working…’ is closed to new replies.