Wordpress:回复评论不起作用

时间:2017-08-17 15:43:13

标签: php wordpress

我很困惑为什么我的代码没有以正确的方式工作。 这是我的comment.php代码:

<div class="comment_output">

<?php foreach($comments as $comment): ?>

    <div class="comment_output_comment" id="<?php echo "comment-" . get_comment_ID(); ?>">
        <div class="comment_info">
            <span class="comment_info_title"><?php comment_author_link(); ?> | <?php comment_date(); ?></span>
        </div>
        <div class="comment_text">
            <?php comment_text(); ?>
            <?php
                $post_id = get_the_ID();
                $comment_id = get_comment_ID();

                //get the setting configured in the admin panel under settings discussions "Enable threaded (nested) comments  levels deep"
                $max_depth = get_option('thread_comments_depth');
                //add max_depth to the array and give it the value from above and set the depth to 1
                $default = array(
                    'add_below'  => 'comment',
                    'respond_id' => 'respond',
                    'reply_text' => __('Reply'),
                    'login_text' => __('Log in to Reply'),
                    'depth'      => 1,
                    'before'     => '',
                    'after'      => '',
                    'max_depth'  => $max_depth
                );

                comment_reply_link($default,$comment_id,$post_id);
            ?>
        </div>
    </div>

<?php endforeach; ?>

</div>

<div class="comment_input comment-respond" id="respond">
    <h2 class="big">Write comment</h2>
    <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
        <input type="text" name="author" placeholder="Name" required class="comment_input_input" id="comment_input_left"/>
        <input type="email" name="email" placeholder="E-Mail" required class="comment_input_input" id="comment_input_right"/>
        <textarea name="comment" placeholder="Comment" required class="comment_input_text comment-form-comment"></textarea>
        <input name="submit" type="submit" value="Comment" id="send" class="comment_button_send"/>
        <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
        <?php do_action('comment_form', $post->ID); ?>
    </form>
</div>

如果我点击回复按钮,comment-input部分不会附加到我想要回复的评论并重新加载页面。 所以我希望你能帮我弄清楚我的错误是什么。

最好的问候。

0 个答案:

没有答案