Home Forums Add-ons Flexible Content Field Can't get data from flexible content field


Can't get data from flexible content field

  • Hi, I just bought ACF Pro and can’t manage to get data from my Flexible Content fields.

    I have a site coded by a real company (I just started dabble) so took their code (that works on our live site) but it isn’t working.

    I can get data from regular Fields

    This is my config
    Field Group: Main Blocks
    Field Name: Main Blocks (main_blocks) (set to Flexible Content)
    First Layout Name: Preamble (preamble)
    First Layout Sub Field: Preamble Text (preamble_text)

    	$main_blocks = get_field( 'main_blocks');
    	if( $main_blocks ):
    		while ( have_rows( 'main_blocks' ) ) : the_row();
    			get_template_part( 'blocks/'.get_row_layout() );
    <?php endif; ?>

    The Block Template for preamble.php

    $preamble_text = get_sub_field( 'preamble_text' );
    if( $preamble_text ):?>
    <div class="container grid grid-guttersXl">
    	<div class="grid-cell">
    		<?php echo $preamble_text; ?>
    <?php endif; ?>

    For error management I tried the first If, but no matter how I write it, it doesn’t return any values.

    Tried with the exact same code as in the forum examples, but still no output.
    Yes, cleared cache and checked that the json output happens.

  • How did you solve this? I am having the same issue.

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

The topic ‘Can't get data from flexible content field’ is closed to new replies.