Created
January 18, 2022 19:58
-
-
Save jas8522/95fe43f0c8293ef8f92c4d8d39b667cc to your computer and use it in GitHub Desktop.
BeaverBuilder Post Grid: Replace Featured Image with First video found in content
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ws_show_first_embedded_video($settings, $module){ | |
$post = $GLOBALS['post']; | |
if (has_category('videos', $post)){ | |
//Get the content, apply filters and execute shortcodes | |
$content = apply_filters( 'the_content', $post->post_content ); | |
$embeds = get_media_embedded_in_content( $content ); | |
if (!empty($embeds)){ | |
echo $embeds[0]; | |
} | |
} | |
} | |
add_action( 'fl_builder_post_grid_before_content', 'ws_show_first_embedded_video', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment