Php 循环中的preg_replace只是偶尔起作用
我试图制作一个定制RSS提要,对每篇文章的HTML内容进行一些修改 在模板文件Php 循环中的preg_replace只是偶尔起作用,php,regex,wordpress,preg-replace,Php,Regex,Wordpress,Preg Replace,我试图制作一个定制RSS提要,对每篇文章的HTML内容进行一些修改 在模板文件rss custom.php中,我有以下内容: 在functions.php中,有三个替换项,如下所示: 函数processPostContent(){ $post=get_post(get_the_ID()); $post\u content=strval($post->post\u content); //用h2替换h3和h4标签 $post\u content=preg\u replace(“/解决方案与循环
rss custom.php
中,我有以下内容:
在functions.php
中,有三个替换项,如下所示:
函数processPostContent(){
$post=get_post(get_the_ID());
$post\u content=strval($post->post\u content);
//用h2替换h3和h4标签
$post\u content=preg\u replace(“/解决方案与循环和preg\u replace
没有任何关系。有些帖子的内容不包含任何HTML标记,只包含纯文本。这就是为什么preg\u replace
对它们没有任何影响。但是,当这些内容在RSS提要中呈现时,
标记会自动trong>插入。这让我相信第三次替换被跳过了
第一段。
第二段。
转向
第一段
第二段
您是否尝试过在1个帖子上手动运行3preg\u replace
,但在循环中似乎不起作用?