Support

Account

Home Forums Gutenberg different renderings according to front and back-office

Solving

different renderings according to front and back-office

  • Hello there !
    (I’m french so I gonna try to be explicit)

    I’m working on a project where I have to create gutenbergs blocks using ACF.

    Basically I want to create a block that has a preview in the back office (a simple title for example) and an html rendering on my template page.

    What I did is that I called render_template (for my template page) and render_callback(for the back-office). But it only takes in count render_callback both for my back-office and template :

    add_action('acf/init', 'my_acf_init_block_types');
    function my_acf_init_block_types() {
    
        // Check function exists.
        if( function_exists('acf_register_block_type') ) {
    
            // register a testimonial block.
            acf_register_block_type(array(
                'name'              => 'section_main_home',
                'title'             => __('Section principale'),
                'description'       => __('Section principale de la page d\'acceuil.'),
                'render_template'   => 'template-parts/blocks/home/section_main_home.php',
                'category'          => 'custom-blocks-peb',
                'icon'              => 'schedule',
                'mode'              => 'auto',
                'render_callback'   => 'my_acf_block_render_callback',
                'enqueue_style'     => get_template_directory_uri() . '/css/blocks.css',
                'keywords'          => array( 'section_main_home', 'main', 'home', 'section' ),
            ));
        }
        
    }

    How can I have front and back-office with two different renderings ?

    Thanks for your replies !

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.