Possiamo sfruttare gli shortcode di WordPress per automatizzare l'inserimento dei video presi da YouTube. Vediamo come fare.
Aggiungete il seguente codice al file functions.php
:
function youtube($atts) {
extract(shortcode_atts(array(
"value" => 'http://',
"width" => '475',
"height" => '350'
), $atts));
return '<iframe src="' . $value .'" width="' . $width . '" height="' . $height . '" allowFullScreen="true" /></iframe>';
}
add_shortcode("youtubevideo", "youtube");
Ecco un esempio d'uso:
[youtubevideo value="http://www.youtube.com/watch?v=1aBSPn2P9bg"]