【问题标题】:How to Remove an HTML tag from XML feed in Wordpress如何从 Wordpress 中的 XML 提要中删除 HTML 标记
【发布时间】:2013-12-19 18:17:30
【问题描述】:

所以我有一个 xml 提要,由于某种原因显示价格标签(我什至不知道这是否是一个有效的 HTML 标签,当然它在尖括号中显示为“价格/”)在每个人下面博客文章导致提要无法验证(显示 65 次)。我想从提要中删除它并尝试将这段代码添加到 functions.php 文件中:

function rss_nopricetag($content) {
$content = preg_replace( '/<price/>/is', '', $content );

return $content;
}

add_filter('the_excerpt_rss', 'rss_nopricetag');
add_filter('the_content_feed', 'rss_nopricetag');

无济于事,我使用下面的代码从我的提要中删除标签,它工作得很好。

function rss_noiframe($content) {
$content = preg_replace( '/<iframe(.*)\/iframe>/is', '', $content );

return $content;
}

add_filter('the_excerpt_rss', 'rss_noiframe');
add_filter('the_content_feed', 'rss_noiframe');

我做错了什么?

【问题讨论】:

    标签: php xml wordpress rss


    【解决方案1】:

    尝试转义价格正则表达式中的斜线。

    $content = preg_replace( '/<price\/>/is', '', $content);
    

    【讨论】:

    • 不幸的是没有工作:(你有什么建议吗?
    • 确定它的 0
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-04-13
    • 2020-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多