Need help? Check out our Support site, then


[Plugin: WP-PageNavi] Paginate all posts on single.php page

  1. Using the latest WordPress and WP-PageNavi. The plugin works great on the index and archive pages but when I try to use it on the single page it ends up appending the paging arguments to the end of the single post url (eg. http://domain/2010/03/02/post-name/page/2/) which results in the same page getting loaded.

    Just to be clear what i'm trying to do here is show a single post and then list all the posts below it (the same as is shown on the index page). Going to the second page should again load the same single post but list the second page of the total results. An alternative solution that would be acceptable would be for paging to just act as if a page button was hit on the index page (eg. route to http://domain/page/2/).

    Any help on how to get the behavior I need would be great. Thank you and I've put code snippets from single.php below.

    <?php get_header(); ?>
    	<!-- content -->
    	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<!-- post -->
    		<div class="videobox" id="post-<?php the_ID(); ?>">
    			<div class="left">
    				<div class="videopanel">
    					<div class="title">
    						<h1><?php the_title(); ?></h1>
    					</div>
    					<div class="contentbody">
    						<center>
    						<?php $video_code = thman_getcustomfield('video_code',get_the_ID()); if(!empty($video_code)) : ?><center><div class="video_code"><?php echo $video_code; ?></div></center><?php endif; ?>
    						</center>
    					</div>
    				</div>
    			</div>
    			<div class="right">
    				<div class="panel">
    <center>
    </center>
    				</div>
    			</div>
    		</div>
    		<div class="videodesc">
    <table><tr><td>
    			<h1><?php the_title(); ?></h1>
    			<p><?php the_content('Read the rest of this entry »'); ?></p>
    			<?php $categories = get_the_category(get_the_ID());?>
    			<h2><span>Categories:</span>
    				<?php foreach($categories as $cat):?>
    				<a href="<?php echo get_option('home').'/?cat='.$cat->cat_ID;?>"><?php echo $cat->name;?></a>
    				<?php endforeach;?>
    			</h2>
    			<h2><span>Date Added:</span> <?php the_date();?> at <?php the_time();?></h2>
    			<h2><span>Length:</span> <?php $duration = thman_getcustomfield('duration',get_the_ID()); if(empty($duration)) $duration = '0:00'; echo $duration; ?></h2>
    			<h2><span>Views:</span> <?php if(function_exists('the_views')) the_views();?></h2>
    			<h2><span>Rating:</span><?php if(function_exists('the_ratings')) the_ratings();?></h2>
    </td><td></td></tr></table>
    		</div>
    		<!-- /post -->
    		<?php comments_template(); ?>
    	<?php endwhile; else: ?>
    		<p class="nopost">Sorry, no posts matched your criteria.</p>
    	<?php endif; ?>
    
    	<!-- content -->
    	<?php
    		$wp_query = new WP_Query();
    		$wp_query->query('');
    	?>
    	<div class="panel">
    		<div class="title">
    			<?php //check if title needs to be set
    				$title = 'Posts for Today';
    				if(isset($_GET['r_sortby']) && $_GET['r_sortby']=='highest_rated') $title = 'Highest Rated';
    				if(isset($_GET['v_sortby']) && $_GET['v_sortby']=='views') $title = 'Most Viewed';
    				if(isset($_GET['c_sortby']) && $_GET['c_sortby']=='most_commented') $title = 'Most Commented';
    			?>
    			<h1 class="main_title">My <?php echo $title;?></h1>
    			<h2><?php echo wp_get_todays_post_count();?> New Posts Added Today, <?php echo wp_get_total_post_count();?> Total</h2>
    		</div>
    		<div id="content" class="contentbody">
    			<?php if($wp_query->have_posts()):?>
    				<?php $i=0; while ($wp_query->have_posts()) : $wp_query->the_post(); $i++; ?>
    				<?php if($i%4==1) : ?><div class="update-row"><?php endif; ?>
    					<div class="update-entry">
    						<a class="thumbs" href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php $thumb = thman_getcustomfield('thumb',get_the_ID()); if(!empty($thumb)) : ?>
    							<img src="<?php echo $thumb; ?>" width="240" height="180" border="0" alt="<?php the_title_attribute(); ?>" />
    						<?php else : ?>
    							<img src="<?php bloginfo('template_url'); ?>/images/pic_empty.gif" alt="<?php the_title_attribute(); ?>" />
    						<?php endif; ?></a>
    						<h1><?php echo thman_get_limited_string($post->post_title,15); ?></h1>
    						<h2><?php $duration = thman_getcustomfield('duration',get_the_ID()); if(empty($duration)) $duration = '0:00'; echo $duration; ?> Min | <?php if(function_exists('the_views')) { the_views(); } ?> | <?php comments_number('0', '1', '%'); ?> Comments</h2>
    						<?php if(function_exists('the_ratings')) { ?><div class="update-rating"><?php the_ratings(); ?></div><?php } ?>
    					</div>
    				<?php if($i%4==0) : ?></div><?php endif; ?>
    				<?php endwhile; ?>
    			<?php else:?>
    				<p class="nopost">Sorry, but you are looking for something that isn't here.</p>
    			<?php endif;?>
    			<?php
    			//echo $wp_query->request;
    			$next_page = get_next_posts_link('Previous');
    			$prev_pages = get_previous_posts_link('Next');
    			if(!empty($next_page) || !empty($prev_pages)) :
    			?>
    			<!-- navigation -->
    			<div class="navigation">
    				<?php if(!function_exists('wp_pagenavi')) : ?>
    		        <div class="alignleft"><?php echo $next_page; ?></div>
    				<div class="alignright"><?php echo $prev_pages; ?></div>
    		        <?php else : wp_pagenavi(); endif; ?>
    			</div>
    			<!-- /navigation -->
    			<?php endif; ?>
    		</div>
    	</div>
    
    <?php get_footer(); ?>

    The blog I need help with is codebyalex.wordpress.com.

  2. You are in the wrong forum. We cannot help you here ate wordpress.COM. The correct forum forum you is here > http://wordpress.ORG/support/

  3. Hi, azenalex. This support forum is for blogs hosted at WordPress.com. You'll find help at the WordPress.org forums.

  4. whoops sorry about that

Topic Closed

This topic has been closed to new replies.

About this Topic