Advertisement
TheMightyAnt

Nested repeater first value

Nov 25th, 2015
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.85 KB | None | 0 0
  1.       <?php // Repeater Field
  2.       if( have_rows('top_5', 'options') ): ?>
  3.        
  4.          <ul>
  5.        
  6.          <?php while( have_rows('top_5', 'options') ): the_row();
  7.        
  8.             // vars (repeater)
  9.             $country_id = get_sub_field('country');
  10.             $country_name = get_the_title( $country_id );
  11.             $permalink = get_the_permalink( $country_id );
  12.             $n = 1;
  13.            
  14.             // check for rows (sub repeater)
  15.             if( have_rows('the_index', $country_id) ):
  16.            
  17.                $i = 0;
  18.                
  19.                // loop through rows (sub repeater)
  20.                while( have_rows('the_index', $country_id) ): the_row();
  21.            
  22.                   // vars (sub-repeater)
  23.                   $pi_id = get_sub_field('philanthropist');
  24.                   $pi_id_1 = $pi_id[0];
  25.                   $pi_name = get_the_title( $pi_id );
  26.                   $pi_image = get_field('image', $pi_id);
  27.                   $pi_image_url = !empty( $pi_image ) ? $pi_image['sizes']['thumbnail'] : get_template_directory_uri() . '/images/article-default-4x3.png';
  28.                   // stop after x number of loops
  29.                   if (++$i == 1) break;
  30.                  
  31.                endwhile;
  32.                
  33.             endif; // if( get_sub_field('sub-repeater') ): ?>
  34.            
  35.                   <a href="<?php echo $permalink; ?>" class="aside-link animate-all group">
  36.                      <img src="<?php echo $pi_image_url; ?>" class="responsive aside-thumb animate-all" alt="<?php echo $pi_name; ?>">
  37.                      <h4 class="animate-all"><?php echo $country_name; ?></h4>
  38.                      <p><?php //No 1: ?><?php echo $pi_name; ?></p>
  39.                   </a>
  40.        
  41.          <?php endwhile; ?>
  42.        
  43.          </ul>
  44.        
  45.       <?php endif; // End Repeating items ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement