Support

Account

Home Forums Add-ons Repeater Field Ternary PHP for Repeater Field

Helping

Ternary PHP for Repeater Field

  • Hi,

    I’m using a theme that is requiring me to write my PHP in ternary (for the output of a function I can’t use “if” statements – it says “unexpected if” – so after a bit of googling I found that I need write in ternary to avoid this).

    I’m trying to include a repeater field. My code would be:

    <ul>
    // check if the repeater field has rows of data
    if( have_rows('repeater_field') ):
    
        // loop through the rows of data
        while ( have_rows('repeater_field') ) : the_row();
    
            // display a sub field value ?>
            <li><a href="<?php the_sub_field('sub_field'); ?>'" target="_blank"><?php the_sub_field('sub_field'); ?></a></li>
    
        <?php endwhile;
    
    else :
    
        // no rows found
    
    endif; 
    </ul>

    But I really don’t know where to begin with this. Could anyone help please?

  • Hey –

    I have the exact same question and saw that this went unanswered. Did you ever figure it out?

    Thanks!

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

You must be logged in to reply to this topic.