load separate block from THE_conten()
-
Hello, I’m using this function to call a block
but what I want is to use the second block of media$blocks = parse_blocks($post->post_content); foreach ($blocks as $block) { if ('core/media-text' === $block['blockName']) { echo apply_filters('the_content', render_block($block)); break; } }
if i use continue; it loads all the media-text blocks and i just want to use the second one
I made this code but I can’t understand how it works, can you help me ?
foreach ($blocks as $block) { if ($blocks[0]['blockName'] === 'media-text') { if ($block['blockName'] === 'media-text' && $block_counter === 0) { $block_counter++; continue; } } }
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘load separate block from THE_conten()’ is closed to new replies.