Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save GauravKhupse/5c3392f74ef97f56c40ee1fbbc2bb451 to your computer and use it in GitHub Desktop.
Save GauravKhupse/5c3392f74ef97f56c40ee1fbbc2bb451 to your computer and use it in GitHub Desktop.
Custom layout 404 hook not working with embedded link
function ensure_autoembed_on_embed_blocks( $block ) {
global $wp_embed;
if ( $block['blockName'] === 'core/embed' && strpos( $block['innerContent'][ 0 ], '</iframe>' ) === false ) {
$block['innerContent'][ 0 ] = $wp_embed->autoembed( $block['innerContent'][ 0 ] );
}
return $block;
}
add_action('astra_404_content_template','ensure_autoembed_on_embed_blocks_404',10,1);
function ensure_autoembed_on_embed_blocks_404( $block ) {
add_filter( 'render_block_data', 'ensure_autoembed_on_embed_blocks', 10, 1 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment