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

how to create a conditional content_width for a wordpress theme?

No, its not possible. $content_width is a theme-wide constant, and its set in functions.php before any of the query conditionals are set. $content_width is used to determine the intermediate image sizes in image_send_to_editor. The “large” image size will be set to the value of $content_width. If you need to modify those sizes on a per-category … Read more

When oEmbed fails, display an alternative

I think the best thing to do in this case is to wrap your oEmbed content with a div before they are rendered and then show an alternate image with the CSS background-image property. If the video loads, then the oEmbed content will cover the background image. You can add the wrapper using the embed_oembed_html … Read more

What are the Oembed Links For?

Those are links for the wordpress “self” oEmbed. It provides the URLs needed to enable embeding the content of the wordpress site in other sites and they are resuired for oEmbed Discover You are right that they are for other sites to consume your content, and if you don’t care about it, just remove it. … Read more

WP Oembed not passing through the “autoplay=1” variable

Those are not really arguments like for YouTube, more of arguments for WordPress itself. One way to handle it would be to access your argument later inside of a filter and modify HTML output. Pass in arguments array: wp_oembed_get( ‘http://www.youtube.com/watch?v=’, array( ‘autoplay’ => 1 ) ); And filter: add_filter(‘oembed_result’,’oembed_result’, 10, 3); function oembed_result($html, $url, $args) … Read more

How to wrap oEmbed-embedded video in DIV tags inside the_content?

The embed_oembed_html filter runs before an oEmbed resource’s HTML is outputted, so you could hook into this and wrap the output in a div as below. I can’t think of a simple way of wrapping the other content. add_filter(’embed_oembed_html’, ‘my_embed_oembed_html’, 99, 4); function my_embed_oembed_html($html, $url, $attr, $post_id) { return ‘<div id=”video”>’ . $html . ‘</div>’; … Read more