0

我正在为我的博客开发一个 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>&nbsp; |&nbsp; <?php comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'reply_text' => 'Reply &nbsp;|&nbsp; ', 'max_depth' => $args['max_depth'] ) )); ?><a href="">Report this comment</a></div>            
        </div>
    <div class="clear"></div>
    <?php
}
endif;
4

0 回答 0