Support

Account

Home Forums Gutenberg Preview parm on acf_register_block_type callback fn Reply To: Preview parm on acf_register_block_type callback fn

  • So, to “fix” my own issue here:

    The preview parameter is not correctly passed on by ACF, so i could not use that.
    I created my own preview paramter just by checking if we are in the adminbackend or not.

    So the renderblock is as followed:

    function fn_render_block_podcast( $block ) {
    
    	// are we in the backend?
    	$is_preview = is_admin() ? true : false;
    
    	$context = [];
    	// Store field values
    	$context['podcast_link'] = get_field( 'podcast_link' );
    	$context['is_preview']   = $is_preview;
    
    	// Render the block.
    	\Timber::render( get_template_directory() . '/templates/ACF-blocks/' . strtolower( $block['title'] ) . '/' . strtolower( $block['title'] ) . '.twig', $context );
    
    }