Support

Account

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

Solved

Checking for content in Repeater sub_field

    • scmjohns

    • September 11, 2013 at 11:09 am

    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 } ?>
    
    • scmjohns

    • September 11, 2013 at 1:47 pm

    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)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.