当你修改一个评论的时候,是否会存在一种需求,就是在本页面里面看到关联文章的所有评论呢?
如果有这样的需求,那么本文值得你看看。
直接将下方的所有代码添加到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 '[art id="346" unique_number="art_cd86cb918d3140d3af24b077337419d1"]' . __( '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' ); } }
安装上方代码之后效果如下:
感兴趣的朋友可以自己去尝试一下,直接复制黏贴就可以了,操作起来没有任何难度。