简体   繁体   English

WordPress的comment_text()函数添加 <p></p> 自动

[英]Wordpress' comment_text() function adds <p> </p> automatically

the code is: 代码是:

<?php comment_text(); ?>

it's output is: 它的输出是:

<p>Comment text</p>

when I change it as: 当我将其更改为:

<p><?php comment_text(); ?></p>

it's output becomes: 它的输出变为:

<p></p>
<p>Comment text</p>

the question is: can I delete the <p></p> tag which becomes automatically? 问题是:我可以删除自动变为<p></p>标签吗? and add my <p></p> tag or add nothing? 并添加我的<p></p>标记或不添加任何内容?

Use get_comment_text() to get the text without display: 使用get_comment_text()获取不显示的文本:

<p><?php echo get_comment_text(); ?><p>

Then you can do whatever you want, like 然后,您可以做任何您想做的事,例如

<p class="myClass"><?php echo get_comment_text(); ?><p>

https://codex.wordpress.org/Function_Reference/get_comment_text https://codex.wordpress.org/Function_Reference/get_comment_text

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM