Shortcode: Embed iFrame

Add following snippet to “functions.php”

Usage

[iframe href="http://www.google.com" height="480" width="640"]

Snippet

add_shortcode('iframe', 'iframe_func');
function iframe_func( $atts ) {
    extract( shortcode_atts( array(
        'href' => 'http://www.wordpress.com',
        'height' => '550px',
        'width' => '600px',     
    ), $atts ) );

    return '<iframe src="'.$href.'" width="'.$width.'" height="'.$height.'"> <p>Your Browser does not support iframes.</p></iframe>';
}

One Response to Shortcode: Embed iFrame

  1. Very helpful, thank you so much!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>