Home Forums Gutenberg Force Custom Block Position


Force Custom Block Position

  • Is there a way to force an acf custom block to the top of a page. Specifically to create a featured image that you can see in the admin through Gutenberg.

  • You can force an ACF custom block to show each new Page that is created by setting up a Gutenberg template that includes the block you’d like, with this code:

    function pages_guten_template() {
        $post_type_object = get_post_type_object( 'page' );
        $post_type_object->template = array(
            array( 'acf/custom-block-name' ),
    add_action( 'init', 'pages_guten_template' );

    More details on templates can be found here (including how to lock it in place, if you so desire).

  • Thank you Graphix for your response. This seems to allow me to do two things…

    1. prevent insertion of new blocks, move existing blocks, or delete blocks.
    2. prevents inserting or removing blocks, but allows moving existing blocks.

    I’m looking at locking just one block up top as a ‘featured image’. I still want the ability to add or delete blocks below this one block.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Force Custom Block Position’ is closed to new replies.