Skip to content

Simple iframe Shortcode Plugin

I was unable to find anything that made it easy to paste iframe embed codes into the visual editor. The existing solutions all required me to transpose info from the embed code to the shortcode. This allows you to simply paste your iframe code. Just put it inside [iframe][/iframe].

Update: Now available in repository as plugin ready to go

add_shortcode( 'iframe', 'simple_iframe_sc' );

function simple_iframe_sc( $atts, $content = null ) {
    $char = array( '‘', '’', '“', '”', '′', '″' );
    $replace = array( "'", "'", '"', '"', "'", '"' );
    return html_entity_decode( str_replace( $char, $replace, $content ) );

Example use:

[iframe]<iframe width="560" height="315" src="" 
frameborder="0" allowfullscreen></iframe>[/iframe]

Schedule Your Discovery Call

Give us 30 minutes to get to know each other, to learn about your business and objectives. We'll offer solutions, advice and an honest assessment of how we can help you.

Posted in