我正在为我的博客开发一个wordpress主题。我在后端启用了2级嵌套注释。问题是,当我点击“回复此评论”链接时,评论回复表单会显示在顶部(其中存在“回复此帖子”表单)。但是我想让它出现在那个评论之下。我尝试了所有可能的解决方案,但都失败了。
这是我的comments.php代码:
<?php if ( is_user_logged_in() ) {
$comment_args = array( 'title_reply'=>'',
'fields' => apply_filters( 'comment_form_default_fields', array() ),
'comment_field' =>'<div class="commentText"><textarea name="comment" rows="2" cols="40"></textarea></div>',
'label_submit' =>'Post',
'logged_in_as' =>'',
'comment_notes_after' => '',); ?>
<div class="singleComent">
<div class="givComment">Give a Comment:</div>
<div class="left"><?php echo get_avatar( $comment); ?></div>
<div class="right">
<?php comment_form($comment_args); ?>
</div>
<div class="clear"></div>
</div>
<?php }
else { ?>
<div class="login">You must be <?php wp_loginout($_SERVER['REQUEST_URI']); ?> or <?php wp_register('', ''); ?> to post a comment</div>
<?php } ?>
<!-- Show all Comments Template -->
<div class="commentsList">
<?php wp_list_comments( array(
'type' => 'comment',
'callback' => 'show_comment'
) ); ?>
</div>
这是我在function.php文件中的代码:
function xtreme_enqueue_comments_reply() {
if( get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'comment_form_before', 'xtreme_enqueue_comments_reply' );
if ( ! function_exists( 'show_comment' ) ) :
function show_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment; ?>
<li class="firstComment" id="<?php comment_ID(); ?>">
<div class="replyImg"><img alt="" src="<?php bloginfo('template_directory'); ?>/images/reply.png"></div>
<div class="left"><?php echo get_avatar( $comment, 80 ); ?></div>
<div class="right">
<div class="comAuthor">
<div class="comAuthorLeft"><?php echo get_comment_author() ?></div>
<div class="comAuthorRight"><?php comment_time( 'H:i:s, d M, Y' ); ?> </div>
<div class="clear"></div>
</div>
<hr class="rurel5"/>
<div class="comText"><?php comment_text(); ?></div>
<div class="comFeedback"><a href="">Like it</a> | <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'reply_text' => 'Reply | ', 'max_depth' => $args['max_depth'] ) )); ?><a href="">Report this comment</a></div>
</div>
<div class="clear"></div>
<?php
}
endif;