我不确定要尝试实现此目的但是我试图对所有<p>
标签执行str_replace并将其替换为<br/>
并且它可以正常工作但是后来我释放了我需要用<p>
这是我使用的代码
<?php
$nodecontent = render($content);
$newcontent = preg_replace("/<p[^>]*?>/", "", $nodecontent);
$newcontent = str_replace("</p>", "<br /><br />", $newcontent);
print render($newcontent);
?>
这是我的内容之前的内容
<div property="content:encoded" class="field-item even">
<p>SOME TExT HERE and here and Here..<p>SOME TExT HERE</p> and here and <p>Here..SOME TExT HERE and here and Here..</p>
</p>
</div>
然后我将代码放入其中后看起来像这样它在某种程度上起作用但剥离了<p>
标记
<div property="content:encoded" class="field-item even">
SOME TExT HERE and here and Here..<br/><br/>SOME TExT HERE<br/><br/> and here and <br/><br/>Here..SOME TExT HERE and here and Here..<br/><br/>
</div>
但我希望它看起来像这样,而不会将<p>
标记作为包装器
<div property="content:encoded" class="field-item even"><p>
SOME TExT HERE and here and Here..<br/><br/>SOME TExT HERE<br/><br/> and here and <br/><br/>Here..SOME TExT HERE and here and Here..<br/><br/>
</p></div>
答案 0 :(得分:0)
<script type="text/javascript" >
jQuery(document).ready(function() {
jQuery(".field-item").wrapInner('<p></p>')
});
</script>
<?php $nodecontent = render($content);
$newcontent = preg_replace("/<p[^>]*?>/", "", $nodecontent);
$newcontent = str_replace("</p>", "<br /><br />", $newcontent);
print render($newcontent); ?>