Support

Account

Home Forums Gutenberg Force Custom Block Position

Solving

Force Custom Block Position

    • jfarr

    • May 24, 2019 at 8:09 pm

    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).

    • jfarr

    • May 28, 2019 at 11:59 pm

    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)

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.