Support

Account

Home Forums Gutenberg Acf blocks doest not display

Unread

Acf blocks doest not display

  • Hello there !

    I’m currently working on a custom theme and with ACF & ACF PRO.

    The is the code
    functions.php


    function my_acf_block_render_callback($block) {
    $slug = str_replace('acf/', '', $block['name']);

    if( file_exists( get_theme_file_path("/template-parts/block/${slug}.php") ) ) {
    include ( get_theme_file_path("/template-parts/block/${slug}.php") );
    }
    }

    add_action( 'init', 'register_acf_blocks' );

    function register_acf_blocks() {
    if (function_exists('acf_register_block')) {
    acf_register_block(array(
    'name' => 'hero',
    'title' => __("Hero"),
    "description" => __("Hero block"),
    'render_callback' => 'my_acf_block_render_callback',
    'category' => 'custom',
    'icon' => 'slides',
    'keywords' => array("hero")
    ));
    }
    }

    template-parts/block/hero.php

    <?php /* Block Name: Hero */
    var_dump($block);
    ?>

    Page hero !

    <section id="hero">
    /assets/img/hero.svg" alt="Form">
    <h1>
    We refer for you the best <span>artificial intelligence</span>
    </h1>
    <div>

    <span>Find your app</span>

    Read the article
    </div>
    </section>

    In the Gutenberg preview when I add the block, i have the preview but in the preview page, nothing …

    Gutenberg preview

    Page preview

    Do you know why ?

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.