简体   繁体   English

wordpress:覆盖HTML标记的comment_text

[英]wordpress: override html markup for comment_text

I'm trying to customise the comments.php file in a custom theme. 我正在尝试在自定义主题中自定义comment.php文件。

I'm using 我正在使用

<?php comment_text(); ?>

which seems to output the comment text in <p></p> tags. 似乎会在<p></p>标记中输出注释文本。 I'm aiming to add the class so that it formats as: <p class='lead'></p> (spot the twitter bootstrap css). 我的目标是添加类,使其格式为: <p class='lead'></p> (发现twitter bootstrap css)。

Can anyone help me figure out how to customise these tags... i may want to use other ones <h1> , etc. I've tried apply_filters but I cant get that to work either. 谁能帮我弄清楚如何自定义这些标签...我可能想使用其他<h1>等等。我试过了apply_filters,但我也无法使它起作用。

Any ideas? 有任何想法吗?

I'm not sure what you are trying to do. 我不确定您要做什么。 Are you talking about the p tag that wraps the comment, or the p tag that gets added to the comment? 您是在谈论包装注释的p标签,还是添加到注释的p标签?

You could try replacing 您可以尝试更换

<?php comment_text(); ?>

With: 带有:

<p class='lead'><?php echo $comment->comment_content; ?></p>

You could also you jQuery to add a class. 您也可以在jQuery中添加一个类。 Just make a wrapper with a class of anything, lets say "comment-wrap". 只需用一类东西包装,就说“评论包装”。

<script type="text/javascript">
$(".comment-wrap p").addClass("lead");
</script>

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

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