Home Forums Front-end Issues Conditional returns true for empty field


Conditional returns true for empty field

  • My post’s repeater field is empty:

    My conditional statement seems to be correct:

    <?php if ( 'content' == $settings['post_content'] || is_single() ) {
      if( have_rows('embedded_content') ): ?>
      <div class="embed_area">
    	  <div id="loopedSlider" class="magazine-slider has-pagination woo-slideshow" style="height:auto;">
    		  <ul class="slides">
    		  <?php while( have_rows('embedded_content') ): the_row(); ?>
    		      <?php $embedded_media = get_sub_field('embedded_media'); ?>
    		     <li class="slide">
    		      <?php $embedded_media_caption = get_sub_field('embedded_media_caption'); ?>
    		      <?php echo $embedded_media ?>
    		     <p class="embed_caption"><?php echo $embedded_media_caption ?></p>
    		    <?php endwhile; ?>
       	<script type="text/javascript">
    	jQuery(window).load(function() {
    		var args = {};
    		args.useCSS = false;
    		args.animation = 'slide';
    		args.slideshow = false;
    		args.smoothHeight = true; = true;
    		args.manualControls = '.pagination-wrap .flex-control-nav > li';
    		args.start = function ( slider ) { '.slider-pagination' ).fadeIn();
    		args.prevText = '<span class="icon-angle-left"></span>';
    		args.nextText = '<span class="icon-angle-right"></span>';
    		jQuery( '.woo-slideshow' ).each( function ( i ) {
    			jQuery( this ).flexslider( args );
      <?php endif; ?>
    <?php }; ?>

    But the conditional is coming back positive anyway:

    Thanks for any help you can provide.

  • With your conditional, you mean this:
    if( have_rows(’embedded_content’) ): ?

    I’m pretty sure It’s returning true because in your screenshot you actually have a row. In the settings of a repeater field you can define minimum rows and if you leave that empty, then you can have a repeater field without any rows.

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

The topic ‘Conditional returns true for empty field’ is closed to new replies.