Home › Forums › Gutenberg › Adding ACF blocks to a block template › Reply To: Adding ACF blocks to a block template
Hi Tom,
I was expirimenting with the same thing as i couldnt find information about this.
But for example:
First You create a custom block via acf_register_block:
acf_register_block(
array(
'name' => 'blockname',
'title' => __('title'),
'description' => __('description')
));
Then you can take the name of the acf_block ‘blockname’ and use it as following in your post type template:
$post_type_object->template = array(
array( 'acf/blockname', array() ),
);
Note: If your blockname contains a space or a underscore, acf renames this to a dash, so ‘block_name’ becomes ‘block-name’.
Hope this helps!
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.