I have a big problem. I wrote this code:
$blocks = parse_blocks( $post->post_content );
foreach ( $blocks as $block ) {
if( $block['blockName'] != '' ) {
$blocks_2[] .= render_block( $block );
}
}
$num_blocks = cont($blocks_2);
for ($i = 2; $i <= $num_blocks; $i++) {
echo $blocks_2[$i];
}
Everything is great, but it doesn't display my code blocks (instagram, twitter) in embed format, just as a url.
Can someone help me?
I have a big problem. I wrote this code:
$blocks = parse_blocks( $post->post_content );
foreach ( $blocks as $block ) {
if( $block['blockName'] != '' ) {
$blocks_2[] .= render_block( $block );
}
}
$num_blocks = cont($blocks_2);
for ($i = 2; $i <= $num_blocks; $i++) {
echo $blocks_2[$i];
}
Everything is great, but it doesn't display my code blocks (instagram, twitter) in embed format, just as a url.
Can someone help me?
Share Improve this question asked Dec 17, 2020 at 16:01 user2986284user2986284 11 bronze badge 2 |1 Answer
Reset to default 0You need to apply the_content
filter on the rendered blocks
foreach ( $blocks_2 as $index => $block ) {
can avoid the need for the$num_blocks
variable too, and there's a typocont
should becount
– Tom J Nowell ♦ Commented Dec 17, 2020 at 16:35