How to make a reply box appear below its comment

大兔子大兔子 提交于 2019-12-25 01:23:36

问题


I'm trying to make a reply box appear below its own comment, instead of at the end of all the comments. For anyone trying to create their own Wordpress comment list, it would be very helpful.

As of now, I have tried:

    <div id="div-comment-<?php comment_ID(); ?>" class="reply">
  <?php comment_reply_link(array_merge( $args, array('depth' => $depth, 'add_below' => 'comment-footer', 'max_depth' => $args['max_depth']))) ?>
  <?php delete_comment_link(get_comment_ID()); ?>
</div>
<div id="comment-footer-<?php comment_ID(); ?>" class="comment-footer">
</div>

Where "'add_below' => 'comment-footer'" would send the form below the specific comment's footer. I don't know why that doesn't work.


回答1:


Figured it out! I needed to add the following for add_below to function properly.

Add this to the header:

    <?php
if ( is_singular() && comments_open() && get_option('thread_comments') )
  wp_enqueue_script( 'comment-reply' );
?>

Or add this to the functions:

function theme_queue_js(){
if ( (!is_admin()) && is_singular() && comments_open() && get_option('thread_comments') )
wp_enqueue_script( 'comment-reply' );
}
add_action('wp_print_scripts', 'theme_queue_js');

Reference:

Peter Wilson: Including WordPress’s comment-reply.js (the right way)



来源:https://stackoverflow.com/questions/27997590/how-to-make-a-reply-box-appear-below-its-comment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!