【问题标题】:How to make a reply box appear below its comment如何使回复框出现在其评论下方
【发布时间】:2015-01-17 08:20:20
【问题描述】:

我正在尝试让回复框出现在其自己的评论下方,而不是所有 cmets 的末尾。对于任何试图创建自己的 Wordpress 评论列表的人来说,这将非常有帮助。

到目前为止,我已经尝试过:

    <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'" 会将表单发送到特定评论的页脚下方。我不知道为什么这不起作用。

【问题讨论】:

    标签: php wordpress comments reply


    【解决方案1】:

    想通了!我需要为add_below 添加以下内容才能正常运行。

    将此添加到标题中:

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

    或将其添加到函数中:

    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');
    

    参考:

    彼得·威尔逊:Including WordPress’s comment-reply.js (the right way)

    【讨论】:

      猜你喜欢
      • 2022-11-18
      • 2012-10-02
      • 1970-01-01
      • 1970-01-01
      • 2018-12-15
      • 2020-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多