Support

Account

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.