Call Us - We're Here to Help! 800.675.8896

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]

1 Comment

  1. John Bubriski on March 14, 2014 at 10:10 am

    Thanks for this! Was trying to create a shortcode for dropping in JS, and it kept encoding the quotes! This fixed it immediately, although I’m a little disappointed that they don’t mention this caveat in the documentation.