我有一个客户网站,已要求为特定类别的帖子自定义评论格式。
在我的循环模板中,我有以下内容:
<div id="gallery-commentlist">
<ul class="gallery-commentlist">
<?php wp_list_comments( 'type=comment&callback=gallery_comment'); ?>
</ul>
</div><!-- #gallery-commentlist -->在我的functions.php文件中,我有这个:
<?php function gallery_comment($comment, $args, $depth) {
$GLOBALS['comment'] = $comment; ?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID() ?>">
<div id="comment-<?php comment_ID(); ?>">
<div class="gallery-comment-body">
<p><span class="gallery-comment-author"><?php comment_text() ?>:</span> <?php comment_text() ?></p>
</div>
<div class="comment-meta commentmetadata"><a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ) ?>"> –
<?php get_comment_date() ?> at <?php get_comment_time() ?></a><?php edit_comment_link(__('(Edit)'),' ','') ?>
</div>
</div>
<?php }?>它没有返回任何评论,我的生活,我不知道为什么。我完全遵循了可湿性粉剂规范中的说明。我是不是忽略了什么?
谢谢你的帮助!
ty
发布于 2012-07-05 00:37:22
显然,有某种查询调用作为comments_template()调用的一部分发生,就像循环调用一样。
当我将我的自定义函数放入注释模板中时,它可以完美地工作。
我尝试将注释模板的内容放入我的自定义循环-单个模板中,但不起作用。
最终解决方案是在注释模板中放置一个if{}语句,然后根据结果设置两种不同的布局。
现在一切都像它应该的那样工作。
https://stackoverflow.com/questions/11314504
复制相似问题