Advertisement
alchymyth

no duplicates, 'post__not_in' method

Sep 21st, 2011
459
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.63 KB | None | 0 0
  1. <?php
  2. $c = 1; //init counter
  3. $do_not_duplicate = array(); //init array
  4. $bpr = 3; //boxes per row
  5. $my_query = new WP_Query('category_name=Artists&posts_per_page=3&orderby=rand');
  6. while ($my_query->have_posts()) : $my_query->the_post();
  7. $do_not_duplicate[] = $post->ID ?>
  8.        
  9. <div class="postgrid" id="post-<?php the_ID(); ?>">
  10.  
  11. <div class="postthumb">
  12. <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('grid-post-image'); ?></a><div class="borderthumb"></div><div class="posttitle"><h1><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
  13.   <p><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">Click for more</a></p></div>
  14.   </div>
  15.   </div>
  16.  
  17.    
  18. <?php endwhile; ?>
  19. <div class="clr">
  20. </div>
  21. </div>
  22.  
  23. <div class="gridContainer">
  24.  
  25. <?php
  26. $c = 1; //init counter
  27. $bpr = 3; //boxes per row
  28. $my_query = new WP_Query(array('category_name' => 'performance', 'posts_per_page' => 3, 'orderby' => 'rand', 'post__not_in' => $do_not_duplicate));
  29. while ($my_query->have_posts()) : $my_query->the_post(); ?>
  30.        
  31. <div class="postgrid" id="post-<?php the_ID(); ?>">
  32.  
  33. <div class="postthumb">
  34. <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_post_thumbnail('grid-post-image'); ?></a><div class="borderthumb"></div><div class="posttitle"><h1><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
  35.    <p><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">Click for more</a></p></div>
  36.   </div>
  37. </div>
  38.    
  39. <?php endwhile; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement