Wordpress自定义iframe短代码无法返回iframe

时间:2012-03-04 13:53:25

标签: php wordpress

基本上我想创建一个短代码来将iframe添加到apost / page等。 我尝试了以下内容,但由于某种原因,框架显示为空白。

//custom added functions
add_shortcode('wrap', 'addWrapper'); 
function addWrapper($atts,$content=null){
    extract(shortcode_atts(array(
        "src" => 'http://google.com',
        "height" => '300',
        "width" => '400',
        "scrolling" => 'auto'
    ), $atts));

    return '<div id="iwrapper">
        <iframe src="'.$src.'" height="'.$height.'"  width="'.$width.'" scrolling="'.$scrolling.'"></iframe>
        </div>';

如果我尝试返回任何其他内容,例如简单的HELLO WORLD文本,它返回就好了。为什么wordpress会消除iframe?我也尝试手动发送iframe,但没有(<iframe width="150" height="300" src="http://www.youtube.com" frameborder="0" type="text/html"></iframe>)..

当我使用firebug进行debbug时,我没有看到任何错误:S

 <div id="iwrapper">
<iframe src="http://google.com" height="300" width="400" scrolling="auto"/>
</div>

1 个答案:

答案 0 :(得分:0)

Wordpress有一些安全限制可以删除iframe。但是很难看到上面的示例如何在iframe中加载。你在构建wordpress插件吗?