static variable loop not working in WordPress
Try something like this: function realistic_get_first_embed_video($post_id) { $post = get_post($post_id); $content = do_shortcode(apply_filters(‘the_content’, $post->post_content)); $embeds = get_media_embedded_in_content($content); if (!empty($embeds)) { //check what is the first embed containg video tag, youtube or vimeo $counter = 0; foreach ($embeds as $embed) { // Check condition if count is 0 then // it is the first iteration if( … Read more