Support

Account

Home Forums Add-ons Flexible Content Field Gutenberg Blocks in Flexible Content Fields

Helping

Gutenberg Blocks in Flexible Content Fields

  • We use the Flexible Content Field with the WP Classic Editor. We would like to switch to using Gutenberg because it’s now so easy to create Gutenberg blocks with ACF. So in theory, we don’t really need the Flexible Content field anymore. However, when we use a page builder like Elementor or Beaver Builder, it takes over the Gutenberg or Classic Editor. So it would still be great to have the Flexible Content field in that circumstance. And in that circumstance, it would be fantastic if we could reference the Gutenberg blocks that we created in ACF in the Flexible Content field. That way, on some pages, we could use Elementor to do the fancy layout at the top of the page and the client could use Flexible Content Fields for the rest of the page … AND we wouldn’t have to rebuild ACF field groups and duplicate ACF code that were originally designated for the Gutenberg blocks. Is there a way to assign a Gutenberg block to the a Flexible Content Field?

  • So I found the Clone field from which I can reference the fields from another Field Group. It seems to be working! Now I can have Elementor take over my WP Editor and still have Flexible Fields below it so that my clients can fill in simple content without messing with carefully laid out layouts made with Elementor. One remaining issue is the render_template for the block. I now need to ask if we are in a row_layout or not.

    <?php
    
    //Normal Gutenberg Block
    $quote = get_field("quote");
    
    //See if it's really a Flexible Content Row
    if(get_row_layout() == 'gutenberg_testimonial_block'){
        $quote = get_sub_field('quote');
    }
    ?>
    <div class="acf-block-testimonial">
        <blockquote><?= $quote ?></blockquote>
    </div>

    It would be a little messy on more complicated templates.

    Does my above solution make sense or does anyone else have input on a better way?

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

The topic ‘Gutenberg Blocks in Flexible Content Fields’ is closed to new replies.