Home › Forums › Gutenberg › "Undefined index: id" when using the parse_blocks() function › Reply To: "Undefined index: id" when using the parse_blocks() function
Hello again,
changing the name of the variable $block
to something else in the foreach head fixed the error message.
Example:
$blocks = parse_blocks( get_the_content() );
foreach ($blocks as $blockcontent) {
if( 'acf/blockname' == $blockcontent['blockName'] ) {
if( !empty( $blockcontent['attrs']['data']['field_name'] ) ) {
$title = $blockcontent['attrs']['data']['field_name'];
echo '<p>'. $title .'</p>';
break;
}
}
}
Maybe someone can explain me that? Thanks again.
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.