AdvancedCustomFields / AdvancedCustomFields/acf
No initial load of repeater fields if nested in block template
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 945
- Forks
- 197
- PR merge metrics
- No merged PRs in 30d
Description
Hey @elliotcondon
I use some ACF blocks to create a block template which will create on initial load of a new post.
if ( ! function_exists( 'my_block_template' ) ) :
function my_block_template() {
$post_type_object = get_post_type_object( 'post' );
if( ! $post_type_object ) {
return;
}
$post_type_object->template = array(
array( 'acf/header-with-inner-blocks', array(
'data' => array(
'header_block_style' => 'fullscreen',
'color_or_gradient' => 'bgcolor',
'background_color' => '#6b9ce7',
'remove_overlay' => true,
),
), array(
array( 'acf/site-logo', array(
'data' => array(
'site_logo_select' => 'white',
'site_logo_width' => 140,
),
) ),
array( 'core/spacer', array(
'style' => array('height' => '100px'),
) ),
array( 'core/heading', array(
'content' => __('Coming Soon', 'wphave'),
'textAlign' => 'center',
'textColor' => 'white',
'fontSize' => 'huge-4',
) ),
array( 'core/paragraph', array(
'content' => __('Our website is coming soon.', 'wphave'),
'align' => 'center',
'textColor' => 'white',
'fontSize' => 'large',
) ),
array( 'acf/social-share', array() ),
array( 'core/spacer', array(
'style' => array('height' => '100px'),
) ),
array( 'acf/links', array(
'data' => array(
'links_block_direction' => 'horizontal',
'links_block_separation' => 'separated',
'links_show' => '2',
'links_show_0_link_name' => __('Imprint', 'wphave'),
'links_show_0_link_to_target' => 'custom_link',
'links_show_0_link_to_url' => array(
'title' => __('Imprint', 'wphave'),
'url' => home_url(),
),
'links_show_0_link_to_action' => 'modal',
'links_show_1_link_name' => __('Privacy Policy', 'wphave'),
'links_show_1_link_to_target' => 'custom_link',
'links_show_1_link_to_url' => array(
'title' => __('Privacy Policy', 'wphave'),
'url' => home_url(),
),
'links_show_1_link_to_action' => 'modal',
),
) ),
) )
);
//$post_type_object->template_lock = 'all'; // <-- This block can't modified or removed
}
endif;
add_action( 'init', 'my_block_template', 18 );
This is really cool and works fine.
But in the case of repeater fields, the block is not loaded on initial load of the post.

If I go the block sidebar and adjust something on the fields, the block repeater data is loaded.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the provided my_block_template function and its add_action('init', ...) entry point, using an ACF block containing repeater fields. Compare the initial post load with the state after changing a field in the block sidebar; done means repeater data is loaded on the initial load.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100