Avoid embedding YouTube videos and open them in a new window

How about this shortcode: function alternative_youtube_embed_func( $atts ) { $a = shortcode_atts( array( ‘id’ => ‘ScMzIvxBSi4’ // youtube video ID from video URL ), $atts); return ‘<a href=”https://www.youtube.com/watch?v=’ . $a[“id”] . ‘” rel=”noopener noreferrer” target=”_blank”><img width=”560″ height=”315″ src=”https://img.youtube.com/vi/’ . $a[“id”] . ‘/0.jpg” alt=”link to youtube video” /></a>’; } add_shortcode( ‘alternative-youtube-embed’, ‘alternative_youtube_embed_func’ ); Add a play-button … Read more

oEmbed work on localhost but not on distant server

It’s a missing configuration on the apache hosts file which cause troubles on serveur ‘self call’. For exemple, if serveur is using domain.com, I’ve a timeout when I typing curl domain.com with shh. Adding 127.0.0.1 domain.com in /etc/hosts file and it’s work !

Displaying cf post formats with oembed

<?php if (strstr($audio, ‘<iframe’)) { echo $audio; } else { echo wp_oembed_get( get_post_meta($post->ID, ‘_format_audio_embed’, true) ); } ?> Of course, this would require that you get the custom field with the audio embed code or url into $audio 🙂 Edit – try: <?php $audio = get_post_meta($post->ID, ‘_format_audio_embed’, true); if (strstr($audio, ‘<iframe’)) { echo $audio; } … Read more

Wrap iframes/embeds, but do it before oEmbed happens

WordPress embed the URLs on same filter with priority of 8 in /wp-includes/class-wp-embed.php // Attempts to embed all URLs in a post add_filter( ‘the_content’, array( $this, ‘autoembed’ ), 8 ); and you are parsing content after it with priority of 10 then defiantly you will get the parsed output. You just need to do it … Read more