• crudomatic

    (@crudomatic)


    Could someone please tell me what is wrong with this loop I made – it is only looping once, yet there are 2 posts (for testing):

    <?php
    			$p_loop_count = 1;
    			$p_post_count = $wp_query->post_count;
    			if (have_posts()) : ?>
    			<?php while (have_posts()) : the_post(); ?>
    			<?php if ($p_loop_count == 1) { /* FIRST post */?>
    				<div class="line">
    					<div class="unit size1of1 lastUnit thumbnote">
    						<p>
    							<strong><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></strong><br />
    							<small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link(); ?></small>
    						</p>
    
    						<?php the_excerpt(); ?>
    
    						<p>
    							<small>category: <?php the_category(' ') ?></small><br />
    							<small>tags: <?php the_tags('', ' ', ''); ?></small><br />
    							<small><?php edit_post_link('edit', '', ' | '); ?>  <?php comments_popup_link('no comments »', '1 comment »', '% comments »'); ?></small>
    						</p>
    					</div>
    				</div>
    			<?php } else { /* Is NOT the first post */ ?>
    				<?php if ($p_loop_count % 2) { /* odd */?>
    					<div class="unit size1of2 lastUnit thumbnote">
    						<p>
    							<strong><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></strong><br />
    							<small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link(); ?></small>
    						</p>
    
    						<?php the_excerpt(); ?>
    
    						<p>
    							<small>category: <?php the_category(' ') ?></small><br />
    							<small>tags: <?php the_tags('', ' ', ''); ?></small><br />
    							<small><?php edit_post_link('edit', '', ' | '); ?>  <?php comments_popup_link('no comments »', '1 comment »', '% comments »'); ?></small>
    						</p>
    					</div>
    				</div>
    				<?php } ?>
    				<?php if (!$p_loop_count % 2) { /* even */?>
    					<?php if ($p_loop_count == $p_post_count) { /* the last post */?>
    				<div class="line">
    					<div class="unit size1of2 lastUnit thumbnote">
    						<p>
    							<strong><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></strong><br />
    							<small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link(); ?></small>
    						</p>
    
    						<?php the_excerpt(); ?>
    
    						<p>
    							<small>category: <?php the_category(' ') ?></small><br />
    							<small>tags: <?php the_tags('', ' ', ''); ?></small><br />
    							<small><?php edit_post_link('edit', '', ' | '); ?>  <?php comments_popup_link('no comments »', '1 comment »', '% comments »'); ?></small>
    						</p>
    					</div>
    				</div>
    					<?php } else { /* NOT the last post */?>
    				<div class="line">
    					<div class="unit size1of2 thumbnote">
    						<p>
    							<strong><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></strong><br />
    							<small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link(); ?></small>
    						</p>
    
    						<?php the_excerpt(); ?>
    
    						<p>
    							<small>category: <?php the_category(' ') ?></small><br />
    							<small>tags: <?php the_tags('', ' ', ''); ?></small><br />
    							<small><?php edit_post_link('edit', '', ' | '); ?>  <?php comments_popup_link('no comments »', '1 comment »', '% comments »'); ?></small>
    						</p>
    					</div>
    					<?php } ?>
    				<?php } ?>
    			<?php } ?>
    			<?php $p_loop_count++;
    				endwhile; ?>
    
    			<div class="line">
    				<div id="post-nav" class="unit size1of1 lastUnit aligncenter">
    					<?php next_posts_link('&laquo; Older Entries') ?> &nbsp; <?php previous_posts_link('Newer Entries &raquo;') ?>
    				</div>
    			</div>
    
    			<?php else : ?>
    
    			<h2 class="aligncenter">Not Found</h2>
    			<p class="aligncenter">Sorry, but you are looking for something that isn't here.</p>
    				<?php get_search_form(); ?>
    			<?php endif; ?>

    This has been driving me crazy for the past few days – cannot see why it isn’t working right. Thanks in advance.

The topic ‘The Loop is only looping once!!!!’ is closed to new replies.