问题
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