Advertisement
Guest User

Untitled

a guest
Feb 12th, 2015
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.60 KB | None | 0 0
  1. <?php
  2. $the_query = new WP_Query(
  3. array(
  4.     'post_type' => 'sponsors',
  5.     'posts_per_page' => 4
  6. )
  7. );
  8.  
  9. if ( $the_query->have_posts() ) {
  10.     while ( $the_query->have_posts() ) {
  11.         $the_query->the_post();
  12.  
  13.         $counter = 0;
  14.         echo '<section class="sponsor-row">';
  15.  
  16.             if ( has_post_thumbnail() ) {
  17.                 $counter++;
  18.  
  19.                 echo '<div class="grid half">';
  20.                     echo '<a class="sponsor" href="'.get_the_permalink().'" target="_blank">';
  21.                     the_post_thumbnail( 'full' );
  22.                     echo '</a>';  
  23.                 echo '</div>';
  24.  
  25.                 if ($counter <= 2){
  26.                     echo '</section>';
  27.                 }
  28.             }
  29.         }
  30.     }
  31. wp_reset_postdata();
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement