Support

Account

Home Forums Add-ons Repeater Field Repeater not working Reply To: Repeater not working

  • Ok I fixed this way, getting the subfields separated

    <?php if( have_rows('temas') ) { ?>
    <p class="font-arial fs-13 hint-text">Tema(s) general(es)<br><strong>
        <?php while( have_rows('temas') ): the_row(); ?>
            <?php $post_object = get_sub_field('tema_general'); ?>
            <?php if( $post_object ): ?>
                <?php // override $post
                $post = $post_object;
                setup_postdata( $post );
                ?>
                <li><?php the_title(); ?></li>
                <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
            <?php endif; ?>
        <?php endwhile; ?>
        <?php echo "</strong></p>"; ?>
    <?php } ?>
    
    <?php if( have_rows('temas') ) { ?>
    <p class="font-arial fs-13 hint-text">Tema(s) especifico(s)<br><strong>
        <?php while( have_rows('temas') ): the_row(); ?>
            <?php $post_object = get_sub_field('tema_especifico'); ?>
            <?php if( $post_object ): ?>
                <?php // override $post
                $post = $post_object;
                setup_postdata( $post );
                ?>
                <li><?php the_title(); ?></li>
                <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?>
            <?php endif; ?>
        <?php endwhile; ?>
        <?php echo "</strong></p>"; ?>
    <?php } else {  if ($tg != '') { ?><p class="font-arial fs-13 hint-text">Temática general <br><strong><?php echo $tg; ?></strong></p><?php } 
     if ($te != '') { ?><p class="font-arial fs-13 hint-text">Temática específica<br><strong><?php echo $te; ?></strong></p><?php }
    } ?>

    Now I want to echo the label Tema(s) especific(os) and Tema(s) general(es) only if a specific sub field exist, since now is printing in the case if any of the 2 subfields exists, thank you!