2 out of 2 members found this post helpful.
L-am scris rapid. Il poti adauga in functions.php al temei:
Cod PHP:
function youtube_shortcode($atts, $content = null) {
if (!$content) {
return;
}
// sigur url-ul este de forma: https://www.youtube.com/watch?v=RlQJdkE0HZw, atunci extragem parametrul v
parse_str(parse_url($content, PHP_URL_QUERY), $url_vars);
if (!isset($url_vars['v'])) {
return;
}
$a = shortcode_atts(array(
'width' => 420,
'height' => 315,
), $atts);
return '<iframe width="' . esc_attr($a['width']) . '" height="' . esc_attr($a['height']) . '" src="' . esc_url('https://www.youtube.com/embed/' . $url_vars['v']) . '" frameborder="0" allowfullscreen></iframe>';
}
add_shortcode('youtube', 'youtube_shortcode');