Insertion d’une iframe avec un shortcode WordPress Wordpress Editeur, Iframe, WordPress, WYSIWYG Cette fonction permet d’ajouter rapidement une iframe dans l’éditeur WYSIWYG de WordPress, en l’écrivant avec les mêmes attributs que la balise HTML originale. add_shortcode('iframe', 'kodex_iframe_shortcode'); function kodex_iframe_shortcode($atts){ $a = shortcode_atts( array( 'src' => '', 'width' => '100%', 'height' => '500', 'scrolling' => 'auto', 'class' => 'kodex-iframe', 'frameborder' => '0' ), $atts); $html = '<iframe'; foreach($a as $k=>$v){ $html .= ' '.esc_attr($k).'="'.esc_attr($v).'"'; } $html .= '></iframe>'; return $html; } 12345678910111213141516171819 add_shortcode('iframe', 'kodex_iframe_shortcode');function kodex_iframe_shortcode($atts){ $a = shortcode_atts( array( 'src' => '', 'width' => '100%', 'height' => '500', 'scrolling' => 'auto', 'class' => 'kodex-iframe', 'frameborder' => '0' ), $atts); $html = '<iframe'; foreach($a as $k=>$v){ $html .= ' '.esc_attr($k).'="'.esc_attr($v).'"'; } $html .= '></iframe>'; return $html;} Usage : [iframe src="http://kodex.pierrelebedel.fr" height="800"] 1 [iframe src="http://kodex.pierrelebedel.fr" height="800"] Pas mal !2