Support

Account

Home Forums Add-ons Repeater Field Check if one field only

Solved

Check if one field only

  • Hi, I use repeater field to show (with the js backstretch) different background in every page.

    How can hide navigation button if I have only one background image?
    Here’s my code. Thank you!

    <?php
    $post_id = false;
    if( is_home() )
    {
    	$post_id = 17; //  ID of home blog
    }
    
    if( get_field('background', $post_id) ):?>
    
    <!-- Nav Buttons --> 
     <div id="next"><img src="<?php bloginfo('template_url'); ?>/img/icon-next.png" /></div>
     <div id="prev"><img src="<?php bloginfo('template_url'); ?>/img/icon-prev.png" /></div>
    
    <script language="javascript">
    
    	 jQuery(document).ready(function($) {
    	 
    		 	jQuery("body").backstretch([
    		 	
    		 	<?php while(the_repeater_field('background', $post_id)): ?>
    		 		"<?php the_sub_field('image', $post_id); ?>",
    		 		
    			<?php endwhile; ?>
    		 	
    		 	], {duration:5000, fade: 800});
    		 	
    		 	
    		}); 
    
    </script>
    
    <?php
    endif
    ?>
  • Hi @anto.c
    You can check the amount of rows like so:

    
    $images = get_field('background', $post_id);
    
    if( count($images) > 1 )
    {
    
    }
    

    Hope that helps.

    Thanks
    E

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Check if one field only’ is closed to new replies.