I have an issue on my frontpage template with my button links.
I have made some splitsections in the design, and in the backend ACF i have made a frontpage location specific fieldgroup. Inside this I have a group to the splitsections with the failing link array to my buttons.
I have double checked that my fields have the right names and is of array type. So i am thinking that it is the “indention” of the array that makes the problem?
The markup in my template is this:
$split_section_1 = get_field(‘split_section_1’); //this is the splitsection group
$split_section_1_btn = $split_section_1[‘split_section_1_btn’]; //this is the splitsection group button that fails.
?>
<div class=”grid grid–lg-2x grid__gutterless split_section”>
<div class=”split-section-text px-lg py-lg”>
<h2 class=”text-3xl”><?php echo $split_section_1[‘split_section_1_title’]; ?></h2>
<?php echo $split_section_1[‘split_section_1_text’]; ?>
” title=”<?php echo $split_section_1_btn[‘title’]; ?>” class=”btn–inverse”><?php echo $split_section_1_btn[‘title’]; ?>
</div>
<div class=”split-section-image”>
” alt=”<?php echo $split_section_1[‘split_section_1_image’][‘alt’]; ?>”>
</div>
</div>
I suddently can’t even save the template in wordpress. It just fails with the error message:
Your PHP code changes were not applied due to an error on line 58 of file wp-content/themes/lindhardt/templates/frontpage.php. Please fix and try saving again.
Uncaught TypeError: Cannot access offset of type string on string in wp-content/themes/lindhardt/templates/frontpage.php:58
Stack trace:
I realised that i was missing an s in get_field – so it works with get_fields (array)