确定评论是否是对另一条评论的回复
我已经在谷歌上搜索这个很久了。我正在基于沙盒主题做我自己的主题。现在我来到了评论区。
沙盒主题不添加嵌套评论(如果该评论是对另一个评论的回复)。这使得评论部分有点混乱,无法确定哪个是对另一个评论的回复。
是否有任何 CSS 类可以添加到我的 comment.php
文件中,以便在评论是否是回复时打印出某个 CSS 类?这是因为我希望回复在其回复的评论下方从左侧缩进一点。
I have searched Googled for this quite long now. I'm doing my own theme based on the Sandbox theme. Now I have come to the comment-section.
The Sandbox theme doesn't add nested comment (if the comment is a reply to another comment). Which makes the comment part a bit messy to figure out which is a reply to another comment or not.
Is there any CSS class I can add to my comment.php
file to print out a certain CSS class if the comment is a reply or not? This because I want the reply to be indented from the left a bit under the comment it is an reply to.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
WordPress 函数
comment_class()
添加了各种类,其中之一是“评论深度”。在样式方面,它会告诉您这是否是对另一条评论的回复。如果您出于编程原因需要了解,@pycior 的答案应该可以解决问题。
http://codex.wordpress.org/Function_Reference/comment_class
The WordPress function
comment_class()
adds a variety of classes, one of which is "comment depth." On the styling front, it tells you if it's a reply to another comment.If you need to know for programmatic reasons, @pycior's answer should do the trick.
http://codex.wordpress.org/Function_Reference/comment_class
您可能应该使用 firebug 检查模板的源代码,看看是否有任何额外的类。如果没有,您应该检查注释在注释循环中是否有父级,并在那里更改/添加类。
然后只需通过 css 设置类的样式即可。
You should probably use firebug to check the source of the template and see if there are any extra classes. If not, You should check if a comment has a parent in your comment loop and change/add the class there.
And then just style the class trough css.
您可以尝试使用 http://codex.wordpress.org/Function_Reference/wp_list_comments 。只需编写 PHP 代码,您的注释就会出现在嵌套的页面上,然后您可以制作自己的 CSS,使其看起来像您想要的那样。
You can try to use http://codex.wordpress.org/Function_Reference/wp_list_comments . Just write the PHP code and your comments will appear on your page nested, and then you can make you own CSS so it will look the way you want.