Support

Account

Home Forums Add-ons Repeater Field Checking for content in Repeater sub_field

Solved

Checking for content in Repeater sub_field

  • Hi, I am trying to check to see if a particular sub_field is populated, and if so, show content. Right now I can only get the image section to work. Essentially, I have some fields in a Repeater called casestudy_image and casestudy_video. As I loop through my posts I am pulling content into a slideshow. I cannot get the video to show. Both fields are image type sub_fields pulling the image ID. Thoughts?

    
    <?php
                 	
    	$repeater_rows = get_field('casestudy_images');       // get all the rows
    	$repeater_first_row = $repeater_rows[0];         // get the first row
    	
    	// START SLIDE
    	echo '<div class="client_work_slide">';
                       
        // If the field is an image, show me the image
        if ($repeater_rows[0] = 'casestudy_image') {
    
    	  $repeater_first_row_image = $repeater_first_row['casestudy_image'];  // get the sub field value
    	  $image = wp_get_attachment_image_src($repeater_first_row_image, 'full');
    	  echo '<img src="'.$image[0].'" class="single_client_hero" />'; //url = $image[0];
    	  var_dump($repeater_first_row);
    	  
    	  // If the field is a video, show me the video
    	  
    	} elseif  ($repeater_first_row == 'casestudy_video') {
    
    	  $repeater_first_row_video = $repeater_first_row['casestudy_video'];  // get the sub field value
    	  
    	  $video = wp_get_attachment_image_src($repeater_first_row_video, 'full');
    
    	  ?>
    
          <a href="#" data-reveal-id="videoModal" border="0"><img src="<?php echo $video[0]; ?>" class="single_client_hero" alt="" /></a>
    <?php } ?>
    
  • Solved my own issue. I needed to set some vars and check for true/false on them:

    
    $repeater_first_row_image = $repeater_first_row['casestudy_image']; $repeater_first_row_video = $repeater_first_row['casestudy_video'];
    
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Checking for content in Repeater sub_field’ is closed to new replies.