【问题标题】:Removing iframe tag from feed output从提要输出中删除 iframe 标记
【发布时间】:2013-09-12 21:00:43
【问题描述】:

我需要删除导致我的提要无法工作的 iframe 标记。这是验证器VALIDATOR 的网址。提要的网址是Natural Nigerian Feed。请有人告诉我该怎么做。这非常令人沮丧。这是我为处理它而编写的代码,但它不起作用

function rss_noiframe($content) {
      // filter out iframe here
    $content =  preg_replace( '/<iframe(.*)/iframe>/is', '', $content );
    return $content;
}
add_filter('the_excerpt_rss', 'rss_noiframe');
add_filter('the_content_feed', 'rss_noiframe');
add_filter('the_content_rss', 'rss_noiframe'); 
我把这段代码放在模板的 function.php 中,但无济于事

【问题讨论】:

    标签: php wordpress rss feed


    【解决方案1】:

    这应该替换所有 iframe(大写和小写)

    function rss_noiframe($content) {
          // filter out iframe here
        $content =  preg_replace( '@<iframe[^>]*?>.*?</iframe>@siu', '', $content );
        return $content;
    }   
    

    【讨论】:

    • 这对我不起作用。 iframe 仍然出现。我写的这个函数最好放在哪里?
    【解决方案2】:

    试试这个,它对我有用 -

    $string = preg_replace('/<iframe.*?\/iframe>/i','', $originalString);
    

    :)

    【讨论】:

      猜你喜欢
      • 2020-03-03
      • 1970-01-01
      • 1970-01-01
      • 2013-12-19
      • 1970-01-01
      • 2016-02-15
      • 2014-04-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多