Custom youtube shortcode that uses $content

Shortcode functions accept a second parameter which contains the value in between the shortcode opening and closing tags: function youtube( $atts, $value=”http://” ) { extract( shortcode_atts( array( “width” => ‘620’, “height” => ‘350’, “name”=> ‘movie’, “allowFullScreen” => ‘true’, “allowScriptAccess”=>’always’, ), $atts ) ); return ‘<object style=”height: ‘.$height.’px; width: ‘.$width.’px”><param name=”‘.$name.'” value=”‘.$value.'”><param name=”allowFullScreen” value=”‘.$allowFullScreen.'”></param><param name=”allowScriptAccess” value=”‘.$allowScriptAccess.'”></param><embed … Read more

Embedding Youtube video on comments

Just add the comments to oEmbed. Here’s a small plugin that you can use as MU-Plugin or normal plugin and that should explain what’s going on pretty well. <?php defined( ‘ABSPATH’ ) or exit; /* Plugin Name: (#105942) oEmbed Comments */ add_filter( ‘comment_text’, ‘wpse_105942_oembed_comments’, 0 ); function wpse_105942_oembed_comments( $comment ) { add_filter( ’embed_oembed_discover’, ‘__return_false’, 999 … 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; }

Forcing WP to embedd a video when using a shortcode

There may be a more graceful way to do this, but it works: function shortcode_youtube($atts) { extract(shortcode_atts(array( “id” => ”, “align” => ‘aligncenter’ ), $atts)); global $wp_embed; $content=”‘; $embed = $wp_embed->run_shortcode( $content ); return ‘<div class=”‘.$align.'”>’ . $embed . ‘</div>’; } add_shortcode(“youtube”, “shortcode_youtube”);

YouTube Sidebar Widget – YouTube service unavailable

The plugin uses cURl direkt instead of WordPress’ built in HTTP class. If your sever does not support cURL, the plugin can not work and you got this message. Deinstall the plugin and use another one. Or replace the curl_it() function within the plugin with something stable. Update The workaraound: Open the plugin file youtube-sidebar-widget.php … Read more

How to make my new theme read [youtube id=”id of the video here” width=”600″ height=”350″]?

You can for example: Copy the YouTube shortcode from the old theme to your new theme. Locate the line (most likely in the functions.php file): add_shortcode( ‘youtube’, ‘some_function’ ); and copy this line and the some_function() to your functions.php in your new theme or better yet – create a new plugin file including: /*Plugin Name: … Read more