在编辑评论页面中显示文章所有的评论
  • 3年前
  • 在编辑评论页面中显示文章所有的评论620
  • 当你修改一个评论的时候,是否会存在一种需求,就是在本页面里面看到关联文章的所有评论呢?

    如果有这样的需求,那么本文值得你看看。

    直接将下方的所有代码添加到function.php里面即可,如果不知道如何操作,通过安装下方插件可以解决问题:

    add_action( 'admin_menu', 'all_display_comments_add_meta_box' );
    
    function all_display_comments_add_meta_box() {
        add_meta_box( 'commentsdiv', __( 'Comments' ), 'my_post_comment_meta_box', 'comment', 'normal', 'high' );
    }
    
    function my_post_comment_meta_box( $comment ) {
       $post = get_post( $comment->comment_post_ID ); // manually define $post
    
        // Add the post ID input.
        echo '';
    
        // Then the AJAX nonce.
        wp_nonce_field( 'get-comments', 'add_comment_nonce', false );
        $total         = get_comments(
            array(
                'post_id' => $post->ID,
                'number'  => 1,
                'count'   => true,
            )
        );
        $wp_list_table = _get_list_table( 'WP_Post_Comments_List_Table' );
        $wp_list_table->display( true );
    
        if ( 1 > $total ) {
            echo '

    ' . __( 'No comments yet.' ) . '

    '; } else { $hidden = get_hidden_meta_boxes( get_current_screen() ); if ( ! in_array( 'commentsdiv', $hidden, true ) ) { ?>

    id ) { wp_enqueue_script( 'post' ); wp_enqueue_script( 'admin-comments' ); } } add_action( 'in_admin_header', 'my_in_admin_header' ); function my_in_admin_header() { if ( 'comment' === get_current_screen()->id ) { wp_comment_reply( '-1' ); } }
    [art id="346" unique_number="art_cd86cb918d3140d3af24b077337419d1"]

    安装上方代码之后效果如下:

    感兴趣的朋友可以自己去尝试一下,直接复制黏贴就可以了,操作起来没有任何难度。

  • 联系我们
  • 有任何疑问欢迎联系我们
  • WP新手学园
  • 在编辑评论页面中显示文章所有的评论
  • 邮箱:2830776172#qq.com(#换成@)
  • 回复时间:9:00-19:00
  • 如果提问.请图文并茂,详细描述问题
  • 在编辑评论页面中显示文章所有的评论
  • 微信号:wpxsxy_official
  • 仅支持付费解决问题
  • *并非所有问题都会被回复
  • 在编辑评论页面中显示文章所有的评论
  • QQ:2830776172
  • 回复时间:9:00-19:00
  • QQ仅支持付费提问,时间有限,尽情谅解
  • 在编辑评论页面中显示文章所有的评论
  • QQ群:198768181
  • 有问题可以进去提问,寻求群友帮助
  • *并非所有问题都会被回复
  • 在编辑评论页面中显示文章所有的评论
  • 咸鱼:WP新手学园
  • 如果对于直接交易不放心,可以走闲鱼
  • *咸鱼价格不作为最终交易价格
  • 备案号:鄂ICP备2021011647号-1