【问题标题】:Ampersand in Wordpress ShortcodeWordpress 简码中的和号
【发布时间】:2012-08-15 20:05:15
【问题描述】:

我为 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”之前的 & 符号如下所示:

&#038;

【问题讨论】:

  • 只是有点谷歌搜索...wordpress.org/support/topic/…
  • 这不是我的问题...我的问题在于替换代码,而不是短代码
  • 你能发布整个输出吗?不仅仅是&符号的样子?
  • &lt;div class="video-shortcode"&gt;&lt;iframe width="600" height="365" src="/watch.php?file=7002_504_720p.mp4&amp;#038;img=/public/images/ss12preview.jpg" frameborder="0" scrolling="no" allowfullscreen&gt;&lt;/iframe&gt;&lt;/div&gt;
  • @Matt 这样吗?你有什么想法吗?

标签: php html wordpress function shortcode


【解决方案1】:

类似的问题可以使用php的html_entity_decode函数

【讨论】:

    【解决方案2】:

    我遇到了类似的问题。几乎没有什么事情不会破坏基本的 Wordpress 功能。要打破基本的 WP 功能,请参阅this answer。对于“正确”的答案,请参阅this answer。我成功地使用了后者。

    基本上使用&amp;amp; 而不是其他 html 实体,因为这被认为是正确的 XML,并由浏览器在 iFrame 标记中解析。

    【讨论】:

      猜你喜欢
      • 2011-06-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-21
      相关资源
      最近更新 更多