Video, embed, html block usage out of the_content

Question

I have tried hundreds ways but i couldn’t do yet. I am beginner, please someone help me !

When admin use for add/upload/embed video any 3 of these blocks; video, core-embed and html i will show the output without use the_content.


function swvideo( $html) {

if ( $html ) {
    return $html;
}

$post = get_post( $post );
if ( ! $html ) {
    return $html;
}

if ( ! function_exists( 'has_blocks' ) ) {
    return $html;
}

if ( ! has_blocks( $post->post_content ) ) {
    return $html;
}

$pattern = "/<!-- wp:html.*-->([sS]*?)<!-- /wp:html -->/i";
preg_match_all( $pattern, $post->post_content, $html );
if ( ! empty( $html[1] ) ) {
    $html = reset( $html[1] );
}

return $html;

}

add_filter( ‘the_content’, ‘swvideo’);

0
, , Ersin 4 years 2020-02-23T08:38:29-05:00 0 Answers 74 views 0

Leave an answer

Browse
Browse