Support

Account

Home Forums Add-ons Flexible Content Field Prevent access variable outside get_row_layout()

Unread

Prevent access variable outside get_row_layout()

  • Hello, I created variables to get the value of my get_sub_field() inside the get_row_layout() and I have encountered an issue. I can still access the variables even I’m not inside in the get_row_layout() or even outside of the while loop. I just created the variable inside the get_row_layout() but I can still access and output the value. I expected that it will have an error like “unexpected variable”.

    
    <?php if( have_rows('property_paragraph_flexible_field') ): ?>
        <?php while ( have_rows('property_paragraph_flexible_field') ) : the_row(); ?>
            <?php
            // Case: Paragraph layout 1
            if( get_row_layout() == 'property_paragraph_flexible_field_layout1' ):
                $m_id = get_sub_field('property_paragraph_flexible_field_layout1_field1');
                $title = get_sub_field('property_paragraph_flexible_field_layout1_field2');
            ?>
            <?php endif; ?>
            <?php echo $title; ?>
        <?php endwhile; ?>
    <?php endif; ?>
    
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.