Add parameter to first post only

Use the property current_post of a WP_Query object – it’ll be zero for the first post: if ( $wp_query->current_post === 0 ) // First post in main loop if ( $get_videos->current_post === 0 ) // First video in current videos loop

oEmbded with wp_insert_post() [embedly]

Read up on Embeds. To trigger an embed use wp_oembed_get($url). In general the url needs to be on it’s own line with a space below and above when inside the_content. wp_insert_post() has nothing to do with embeds as the embed HTML is usually generated when passed through the_content filter. To add support for non-oEmbed sites … Read more

What are available arguments for wp_oembed_get?

The whole idea of embedding is that you do not have control over how the embedded content is being styled and it is controlled by the server from which the content is embedded. The embedding server might allow some control over the embedded content via the URL parameters but to know how to achieve that … Read more

Combine embed_oembed_html and oembed_result

This works, just don’t know if it’s the proper way to do it: Yes, the functions are the same so they’re equivalent. There is nothing wrong here. But if we dig a bit deeper, we see they’re not 2 filters for the same thing at all: embed_oembed_html filters the cached oEmbed HTML. oembed_result filters the … Read more

WordPress get_media_embedded

Because print_r prints a readable version of your variable $media, which will be an array as per the documentation for get_media_embedded_in_content(). You see Array ( [0] => [youtube embed] ) in your browser because it’s rendering the HTML of the array element – if you check the source code of your page you would see … Read more

Div around YouTube video

I’m not sure why that’s not working except maybe you need to put the returned stuff in a variable? This is what works for me when I put it in my functions.php file: add_filter( ’embed_oembed_html’, ‘tdd_oembed_filter’, 10, 4 ) ; function tdd_oembed_filter($html, $url, $attr, $post_ID) { $return = ‘<figure class=”video-container”>’.$html.'</figure>’; return $return; }