WordPress.org

Forums

[resolved] Custom loop broke pagination (1 post)

  1. at02
    Member
    Posted 3 years ago #

    I made a customized index.php so that I have multiple loops on the same page so that the content can be displayed differently. I got this to work, however the pagination is broken. Despite several hours of Googling and trying all sorts of things, I can't get it to work. Subsequent pages just display the same thing as the home page.

    I'm also using the WP-PageNavi plugin to do the pagination at the bottom. Each subsequent page is correct in the address bar and at the bottom of the page according to the plug-in, but the content is the same on every page.

    Here is the code: (Btw, if there is a better way to do multiple loops, please let me know)

    <!-- First Loop -->
    		<div id="first-post">
    			<?php
    				$temp = $wp_query;
    				$wp_query= null;
    				$wp_query = new WP_Query();
    				$wp_query->query('showposts=1'.'&paged='.$paged);
    
    			?>
    
    			<?php $posts = get_posts('numberposts=1&offset=0'); foreach ($posts as $post) : start_wp(); ?>    
    
    			<?php static $count1 = 0; if ($count1 == "1") { break; } else { ?>
    
    			<div class="post">
    				<div class="post-header">
    					<div class="dateblock">
    						<p class="dateblock-month"><?php the_time(M) ;?></p>
    						<p class="dateblock-day"><?php the_time(d) ;?></p>
    						<p class="dateblock-year"><?php the_time(Y) ;?></p>
    					</div> <!-- close dateblock -->
    
    					<div class="post-title">
    						<h1 class="title"><a href="<?php the_permalink() ;?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
    					</div> <!-- close post-title -->
    				</div> <!-- close post-header -->
    
    				<div class="first-post-thumb"><a href="<?php the_permalink() ;?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_post_thumbnail('first-post-image'); ?></a></div> <!-- close first-post-thumb -->
    
    				<div class="first-post-wrap">
    					<div class="authorinfo"><p class="byline">By <?php the_author(); ?></p></div>
    					<div class="entry">
    						<?php the_excerpt(); ?>
    					</div> <!-- close entry -->
    				</div> <!-- close first-post-wrap -->
    
    				<div class="postmetadata">
    					<?php edit_post_link('Edit'); ?>
    					<?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?>
    					<a href="<?php the_permalink(); ?>" title="Read the rest of <?php the_title(); ?>" class="more-link">Read More &raquo;</a>
    				</div> 
    
    				<div class="clear"></div>
    			</div> <!-- close post -->
    			<?php $wp_query = null; $wp_query = $temp;?>
    
    			<?php $count1++; } ?>
    			<?php endforeach; ?>
    
    		</div> <!-- close first-post -->
    
    		<!-- Second Loop -->
    		<ul class="two-col">
    		<?php
    				$temp = $wp_query;
    				$wp_query= null;
    				$wp_query = new WP_Query();
    				$wp_query->query('showposts=4'.'&paged='.$paged);
    
    		?>
    
    		<?php $posts = get_posts('numberposts=4&offset=1'); foreach ($posts as $post) : start_wp(); ?>
    		<?php static $count2 = 0; if ($count2 == "4") { break; } else { ?>
    
    		<li class="<?php echo (++$j % 2 == 0) ? 'evenpost' : 'oddpost'; ?>">
    			<div class="post">
    				<div class="two-col-thumb"><a href="<?php the_permalink() ;?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_post_thumbnail('two-col-image'); ?></a></div> <!-- close two-col-thumb -->
    				<div class="two-col-title"><h2 class="title"><a href="<?php the_permalink() ;?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2></div> <!-- close two-col-title -->
    				<div class="two-col-author"><p class="byline">By <?php the_author(); ?></p></div> <!-- close two-col-author -->
    			</div> <!-- close post -->
    		</li>
    
    		<?php $count2++; } ?>
    		<?php endforeach; ?>
    		</ul> <!-- close two-col -->
    		<?php $wp_query = null; $wp_query = $temp;?>
    
    		<!-- Third Loop -->
    		<ul class="three-col">
    
    		<?php
    				$temp = $wp_query;
    				$wp_query= null;
    				$wp_query = new WP_Query();
    				$wp_query->query('showposts=6'.'&paged='.$paged);
    
    			?>
    		<?php $posts = get_posts('numberposts=6&offset=5'); foreach ($posts as $post) : start_wp(); ?>
    		<?php static $count3 = 0; if ($count3 == "6") { break; } else { ?>
    
    		<li>
    			<div class="post">
    				<div class="three-col-thumb"><a href="<?php the_permalink() ;?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_post_thumbnail('three-col-image'); ?></a></div> <!-- close three-col-thumb -->
    				<div class="three-col-title"><h3 class="title"><a href="<?php the_permalink() ;?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3></div><!-- close three-col-title -->
    				<div class="three-col-author"><p class="byline">By <?php the_author(); ?></p></div> <!-- close three-col-author -->
    			</div> <!-- close post -->
    		</li>
    
    		<?php $count3++; } ?>
    		<?php endforeach; ?>
    		</ul> <!-- close three-col -->
    
    		<?php $wp_query = null; $wp_query = $temp;?>
    
    		<!-- End All Looping -->

    I'd really appreciate any help figuring this out.

    Additionally, if it helps at all... The first loop is so that the most recent post is one large, single column. The second loop displays the four posts preceding it in two columns. The third loop displays the next six posts in three columns.

Topic Closed

This topic has been closed to new replies.

About this Topic