Support

Account

Home Forums General Issues WP5.9 FSE editor template and ACF blocks

Unread

WP5.9 FSE editor template and ACF blocks

  • Hello,

    I have a problem with the new FSE WP. I edit a template “archive” to dipay my post. I have a custom field “prix” on it. I start a block in my function.php

    I made a reusable block of it to allow to add this one on the FSE editor.

    All is ok in the “classic gutenberg” but in the new editor when I try to modify my template I have an error : nothing happen… and my website is frozen…

    Do u have any ideas ?

    function capitaine_register_acf_block_types() {
    
        acf_register_block_type( array(
            'name'              => 'prix',
            'title'             => 'Prix du cadeau',
            'description'       => "Affiche le prix via ACF",
            'render_template'   => 'blocks/prix.php',
            'category'          => 'formatting',
            'icon'              => 'admin-plugins',
            'keywords'          => array( 'plugin', 'extension', 'add-on' ),
            'enqueue_assets'    => function() {
            	wp_enqueue_style( 'capitaine-blocks', get_template_directory_uri() . '/css/blocks.css' );
            }
        ) );
    }
    
    add_action( 'acf/init', 'capitaine_register_acf_block_types' );

    block/prix.php looks like this

    <?php
    $post = get_queried_object_id();
    //$post = get_the_ID();
    $variable = get_field('prix', $post);
    
    // do something with $variable
    echo $variable;
    
    ?>
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.