I’m using the “acf/load_value” filter to provide a default flex content template for a specific post type. So far I’ve managed to load default layouts just fine, but any content I try to put in them will not appear. Can someone help me find what I’m doing wrong?
This is my filter function:
function default_page_blocks_room( $value, $post_id, $field ) {
$new_value = $value;
$post_type = get_post_type( $post_id );
// La valeur ne sera null que si c'est une nouvelle page
if( null === $value ) {
if( 'room' == $post_type ) {
$new_value = [
[
'acf_fc_layout' => 'small_gallery_text',
'text' =>
'<h2>' . __("Description", 'bonestheme') . '</h2>'
. '<p>' . __("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas varius tortor nibh, sit amet tempor nibh finibus et. Aenean eu enim justo.", 'bonestheme') . '</p>'
. '<ul class="half-width-blocks">'
. '<li>'
. '<strong class="large-text">' . __("Donec libero turpis, lacinia nec leo sit amet, dignissim dignissim lacus.", 'bonestheme') . '</strong>'
. '</li>'
. '</ul>'
],
[
'acf_fc_layout' => 'image_text_juxta'
],
[
'acf_fc_layout' => 'large_gallery',
'title' => __("Galerie d'images", 'bonestheme'),
],
];
}
}
return $new_value;
}
add_filter('acf/load_value/name=page_blocks', 'default_page_blocks_room', 10, 3);
One of my layouts is defined as such:
'small_gallery_text' => [
'key' => 'layout_page_blocks_small_gallery_text',
'label' => __("Petite galerie avec texte", 'bonestheme'),
'display' => 'block',
'name' => 'small_gallery_text',
'sub_fields' => [
[
'key' => 'field_page_blocks_small_gallery_text_gallery',
'label' => __("Galerie d'images", 'bonestheme'),
'instructions' => __("La première image s'affichera en grand par défaut.", 'bonestheme'),
'name' => 'gallery',
'type' => 'gallery',
'wrapper' => [ 'width' => 50 ],
],
[
'key' => 'field_page_blocks_small_gallery_text_text',
'label' => __("Texte adjacent à la galerie", 'bonestheme'),
'name' => 'text',
'type' => 'wysiwyg',
'wrapper' => [ 'width' => 50 ],
],
],
],