我为wordpress创建了一个短代码,来自functions.php的代码如下所示:
return '<div class="video-shortcode"><iframe width="600" height="365" src="/watch.php?file=' . $atts['file'] . '&img=' . $atts['img'] . '" frameborder="0" scrolling="no" allowfullscreen></iframe></div>';
当我使用它时,帖子的源代码应如下所示:
<iframe width="600" height="365" src="/watch.php?file=myfile.mp4&img=myimg.jpg" frameborder="0" scrolling="no" allowfullscreen></iframe>
但出于某种原因,“img”之前的&符号显示为:
&
答案 0 :(得分:1)
要解决类似问题,可以使用php的html_entity_decode函数
答案 1 :(得分:0)
我遇到了类似的问题。没有什么可以做的,不会打破基本的Wordpress功能。要打破基本WP功能,请参阅this answer。对于“正确”的答案,请参阅this answer。我成功地使用了后者。
基本上使用&
而不是其他html实体,因为这被认为是正确的XML并且由浏览器在iFrame标记中解析。