Support

Account

Home Forums Add-ons Repeater Field IF/ELSEIF

Solving

IF/ELSEIF

  • Hello, has anyone used an IF/ELSEIF inside of a Repeater….

    We’re trying to show either an Icon or an Image within a <figure> tag depending on which the user has selected. This “avatar” is appearing within each card in a repeating list of cards…

    <?php 
    			foreach ($section['cards'] as $item => $block) :
    		?>
    			<li class="mdl-cell--2--col demo-card-square mdl-card mdl mdl-shadow--2dp" style="background-color: <?=$section['card_background_color']?>">
    			  <aside class="mdl-list--title--subtitle">
    
    			  	<figure class="mdl-list--avatar" style="background-color:<?=$section['avatar_background_color']?>">
    
    			  		<?php if ($block['use_avatar_image_or_icon'] == 'avatar') { ?>
    			  		<img src="<?=$block['card_avatar']?>" id="avatar__image"/>
    
    			  		<?php } else if ($block['use_avatar_image_or_icon'] == 'icon') { ?>
    						<i style="color:<?=$section['icon_color']?>;" class="fa <?=$block['card_icon']?>" ></i>
    					<?php }?>
    			  	</figure>
    <?php
        endforeach;
    ?>
  • I don’t see anything wrong with your code, but I’m not sure what’s not working? What is being shown and how does it differ from what you want?

  • Hey John, so interestingly neither the <i> or the shows in the source code of a published page. Screenshot of source.

    We’ve got “icon” selected in ACF

  • Actually – I’m not sure myself but it looks like the issue may have cleared up. So maybe it was a caching bug. Sorry about that.

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

The topic ‘IF/ELSEIF’ is closed to new replies.