• Hi,

    I’m using ACF in order to generate new block. Here I’ve a button that call the file template-parts/blocks/button.php as render template :

    add_action('acf/init', 'rt_block_button');
    function rt_block_button() {
    
        if( function_exists('acf_register_block') ) {
            acf_register_block(array(
                'title' => __( 'Bouton', 'rt' ),
                'name' => 'button',
                'category' => 'rt',
                'keywords' => array( 'button', 'bouton', 'kmc', 'finance' ),
                'mode' => 'preview',
                'render_template' => 'template-parts/blocks/button.php',
                'icon' => 'button'
            ));
        }
    }

    My question is pretty simple : Is it possible to separate the block’s render template depending on if we’re on post editor (back-office) or the front website ?

    I already tried to contextualize the template output directly by using the get_current_screen() function, but this last one always returns “null”. I don’t know if it is still usefull since 5.0 and Gutenberg and so.

    Thank you in advance.

    • This topic was modified 3 years, 9 months ago by Nox.
Viewing 1 replies (of 1 total)
  • Good Morning,
    I stumbled across this question while looking for something else and even though it is a few months old, it may be worth me saying how I approach this in case it helps others.

    I use…

    <?php if(is_admin()): ?>
         <!-- Stuff to show in admin -->
    <?php else: >
         <!-- front end of site stuff -->
    <?php endif; ?>

    I usually use this if I’m loading in some sort of slider that is easier to manage in edit mode rather than preview mode so I put a message for the client to click across to edit mode.

    Hope this helps`

    • This reply was modified 3 years, 5 months ago by MikeChipshop.
    • This reply was modified 3 years, 5 months ago by MikeChipshop.
Viewing 1 replies (of 1 total)
  • The topic ‘Separate block render template for post editor and website front’ is closed to new replies.