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 );
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.