Jump to content

[SOLVED] Wordpress Multiple Loops Breaking....Help! :(


Jezthomp

Recommended Posts

I have the following code which is meant to have 3 loops in it, top middle and bottom.

 

However, when viewed its all broken and not displaying right.

 

<?php
/*
Single Post Template: Event Detail
Description: Main page for final drill down of event!
*/
?>


<?php get_header(); ?>

<ul class="banner_ad">
<?php query_posts('cat=14'); ?>  
<?php while (have_posts()) : the_post(); ?> 
<li><?php the_content(); ?></li>				
<?php endwhile;?>  
</ul> 


<?php rewind_posts(); ?>  
<!--end first Loop?-->


<?php if (have_posts()) : ?>

	<?php while (have_posts()) : the_post(); $data = get_post_meta( $post->ID, 'key', true ); ?>	

<div id="detail_holder">	


<div id="detail_image">	

<img src="http://jezthompson.co.uk/ransom_note/wp-content/uploads/<?php echo $data[ 'event_image' ]; ?>" alt = "work image"/>
</div>
<!--detail_image-->	


<div id="detail_right">

			<?php $content = split("<!--more-->", $post->post_content);?>

		<div id="detail_right_title">
		<div id="detail_holder_inner_cat<?php $category = get_the_category(); echo $category[0]->cat_ID;?>">

		<ul>
		<li><?php the_title(); ?></li>
		<li><?php echo $data[ 'event_date' ]; ?> </li>
		<li><?php echo $data[ 'event_location' ]; ?> » <?php echo $data[ 'event_time' ]; ?></li>

		</ul>

		</div>
		<!--detail_holder_inner-->

		</div>
		<!--detail_right_title-->

		<div class="content_box">			
		<?php echo apply_filters('the_content', $content[0]); ?>
		<?php echo apply_filters('the_content', $content[1]); ?>
		</div>
		<!--text content-->

		<div class="content_box">
		<p><a href="mailto:blank?body=The article '<?php the_title(); ?>' has been sent to you. You can view it at: <?php the_permalink() ?>" title="E-mail this item to a friend">Send to a friend</a></p>
		</div>
		<!--send to friend-->

		<div class="content_box">
		<?php echo apply_filters('the_content', $content[2]); ?>
		</div>
		<!--links-->

		<div class="content_box">			

		<ul class="prev_nxt">
		<li class="jFlowPrev"><?php previous_post_link('« %link') ?></li>
		<li class="jFlowNext"><?php next_post_link('%link »') ?></li>
		</ul>
		</div>
		<!--next/previous-->


				<?php endwhile; ?>
<?php endif; ?>


<div class="clearFix"><!--x--></div>			
</div>
<!--detail_right-->	


<div class="clearFix"><!--x--></div>				
</div>
<!--detail_holder-->	


<?php rewind_posts(); ?>  
<!--end middle Loop-->


<ul class="lowerbanner">
<?php query_posts('cat=11'); ?>  
<?php while (have_posts()) : the_post(); ?> 
<li><?php the_content(); ?></li>				
<?php endwhile;?>  
</ul> 


<?php get_footer(); ?>					

 

I dont understand as i've used the 3 loops on other pages, with only the centre one changing on this page its messed it all up.

 

Any ideas? :(

 

Sorted myself with the aid of this tutorial and this bit of code.

 

<?php if (have_posts()) : while (have_posts()) : the_post();
if( $post->ID == $do_not_duplicate ) continue; update_post_caches($posts); ?>

 

My second loop was repeating the first one, not showing its own, so i found that added ...and it then printed its own and ignored the first one.

 

Woooo Hoooo :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.