mardi 24 mars 2015

Multiple Loops on a Page Without Duplicates


I have tried many different versions of this and nothing seems to be working for me. I want to display single posts of a custom post type (portfolio) each in its own div. I don't want any duplicate posts on the page. I need 13 different divs, each containing info about a different post. Link to the page in question: http://ift.tt/1DVSWe3



<div class="port1">
<?php $my_query = new WP_Query( 'post_type=portfolio&showposts=1' );
while ( $my_query->have_posts() ) : $my_query->the_post();
$do_not_duplicate = $post->ID; ?>
<?php the_title(); ?>
<?php endwhile; ?>
</div>

<div class="port2">
<?php while ( $my_query->have_posts() ) : $my_query->the_post();
if ( $post->ID == $do_not_duplicate ) continue; ?>
<?php the_title(); ?>
<?php endwhile; ?>
</div>

<div class="port3">
<?php while ( $my_query->have_posts() ) : $my_query->the_post();
if ( $post->ID == $do_not_duplicate ) continue; ?>
<?php the_title(); ?>
<?php endwhile; ?>
</div>




Aucun commentaire:

Enregistrer un commentaire