post_comment_meta_box

The timeline below displays how wordpress function post_comment_meta_box has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.4

/**
 * Displays comments for post.
 *
 * @since 2.8.0
 *
 * @param WP_Post $post Current post object.
 */
function post_comment_meta_box($post)
{
    wp_nonce_field('get-comments', 'add_comment_nonce', false);
    ?>
	<p class="hide-if-no-js" id="add-new-comment"><button type="button" class="button" onclick="window.commentReply && commentReply.addcomment(<?php 
    echo $post->ID;
    ?>);"><?php 
    _e('Add Comment');
    ?></button></p>
	<?php 
    $total = get_comments(array('post_id' => $post->ID, 'count' => true, 'orderby' => 'none'));
    $wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
    $wp_list_table->display(true);
    if (1 > $total) {
        echo '<p id="no-comments">' . __('No comments yet.') . '</p>';
    } else {
        $hidden = get_hidden_meta_boxes(get_current_screen());
        if (!in_array('commentsdiv', $hidden, true)) {
            ?>
			<script type="text/javascript">jQuery(function(){commentsBox.get(<?php 
            echo $total;
            ?>, 10);});</script>
			<?php 
        }
        ?>
		<p class="hide-if-no-js" id="show-comments"><a href="#commentstatusdiv" onclick="commentsBox.load(<?php 
        echo $total;
        ?>);return false;"><?php 
        _e('Show comments');
        ?></a> <span class="spinner"></span></p>
		<?php 
    }
    wp_comment_trashnotice();
}

WordPress Version: 6.1

/**
 * Displays comments for post.
 *
 * @since 2.8.0
 *
 * @param WP_Post $post Current post object.
 */
function post_comment_meta_box($post)
{
    wp_nonce_field('get-comments', 'add_comment_nonce', false);
    ?>
	<p class="hide-if-no-js" id="add-new-comment"><button type="button" class="button" onclick="window.commentReply && commentReply.addcomment(<?php 
    echo $post->ID;
    ?>);"><?php 
    _e('Add Comment');
    ?></button></p>
	<?php 
    $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 '<p id="no-comments">' . __('No comments yet.') . '</p>';
    } else {
        $hidden = get_hidden_meta_boxes(get_current_screen());
        if (!in_array('commentsdiv', $hidden, true)) {
            ?>
			<script type="text/javascript">jQuery(function(){commentsBox.get(<?php 
            echo $total;
            ?>, 10);});</script>
			<?php 
        }
        ?>
		<p class="hide-if-no-js" id="show-comments"><a href="#commentstatusdiv" onclick="commentsBox.load(<?php 
        echo $total;
        ?>);return false;"><?php 
        _e('Show comments');
        ?></a> <span class="spinner"></span></p>
		<?php 
    }
    wp_comment_trashnotice();
}

WordPress Version: 5.9

/**
 * Display comments for post.
 *
 * @since 2.8.0
 *
 * @param WP_Post $post
 */
function post_comment_meta_box($post)
{
    wp_nonce_field('get-comments', 'add_comment_nonce', false);
    ?>
	<p class="hide-if-no-js" id="add-new-comment"><button type="button" class="button" onclick="window.commentReply && commentReply.addcomment(<?php 
    echo $post->ID;
    ?>);"><?php 
    _e('Add Comment');
    ?></button></p>
	<?php 
    $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 '<p id="no-comments">' . __('No comments yet.') . '</p>';
    } else {
        $hidden = get_hidden_meta_boxes(get_current_screen());
        if (!in_array('commentsdiv', $hidden, true)) {
            ?>
			<script type="text/javascript">jQuery(function(){commentsBox.get(<?php 
            echo $total;
            ?>, 10);});</script>
			<?php 
        }
        ?>
		<p class="hide-if-no-js" id="show-comments"><a href="#commentstatusdiv" onclick="commentsBox.load(<?php 
        echo $total;
        ?>);return false;"><?php 
        _e('Show comments');
        ?></a> <span class="spinner"></span></p>
		<?php 
    }
    wp_comment_trashnotice();
}

WordPress Version: 5.6

/**
 * Display comments for post.
 *
 * @since 2.8.0
 *
 * @param WP_Post $post
 */
function post_comment_meta_box($post)
{
    wp_nonce_field('get-comments', 'add_comment_nonce', false);
    ?>
	<p class="hide-if-no-js" id="add-new-comment"><button type="button" class="button" onclick="window.commentReply && commentReply.addcomment(<?php 
    echo $post->ID;
    ?>);"><?php 
    _e('Add Comment');
    ?></button></p>
	<?php 
    $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 '<p id="no-comments">' . __('No comments yet.') . '</p>';
    } else {
        $hidden = get_hidden_meta_boxes(get_current_screen());
        if (!in_array('commentsdiv', $hidden, true)) {
            ?>
			<script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php 
            echo $total;
            ?>, 10);});</script>
			<?php 
        }
        ?>
		<p class="hide-if-no-js" id="show-comments"><a href="#commentstatusdiv" onclick="commentsBox.load(<?php 
        echo $total;
        ?>);return false;"><?php 
        _e('Show comments');
        ?></a> <span class="spinner"></span></p>
		<?php 
    }
    wp_comment_trashnotice();
}

WordPress Version: 5.5

/**
 * Display comments for post.
 *
 * @since 2.8.0
 *
 * @param object $post
 */
function post_comment_meta_box($post)
{
    wp_nonce_field('get-comments', 'add_comment_nonce', false);
    ?>
	<p class="hide-if-no-js" id="add-new-comment"><button type="button" class="button" onclick="window.commentReply && commentReply.addcomment(<?php 
    echo $post->ID;
    ?>);"><?php 
    _e('Add Comment');
    ?></button></p>
	<?php 
    $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 '<p id="no-comments">' . __('No comments yet.') . '</p>';
    } else {
        $hidden = get_hidden_meta_boxes(get_current_screen());
        if (!in_array('commentsdiv', $hidden, true)) {
            ?>
			<script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php 
            echo $total;
            ?>, 10);});</script>
			<?php 
        }
        ?>
		<p class="hide-if-no-js" id="show-comments"><a href="#commentstatusdiv" onclick="commentsBox.load(<?php 
        echo $total;
        ?>);return false;"><?php 
        _e('Show comments');
        ?></a> <span class="spinner"></span></p>
		<?php 
    }
    wp_comment_trashnotice();
}

WordPress Version: 5.3

/**
 * Display comments for post.
 *
 * @since 2.8.0
 *
 * @param object $post
 */
function post_comment_meta_box($post)
{
    wp_nonce_field('get-comments', 'add_comment_nonce', false);
    ?>
	<p class="hide-if-no-js" id="add-new-comment"><button type="button" class="button" onclick="window.commentReply && commentReply.addcomment(<?php 
    echo $post->ID;
    ?>);"><?php 
    _e('Add Comment');
    ?></button></p>
	<?php 
    $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 '<p id="no-comments">' . __('No comments yet.') . '</p>';
    } else {
        $hidden = get_hidden_meta_boxes(get_current_screen());
        if (!in_array('commentsdiv', $hidden)) {
            ?>
			<script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php 
            echo $total;
            ?>, 10);});</script>
			<?php 
        }
        ?>
		<p class="hide-if-no-js" id="show-comments"><a href="#commentstatusdiv" onclick="commentsBox.load(<?php 
        echo $total;
        ?>);return false;"><?php 
        _e('Show comments');
        ?></a> <span class="spinner"></span></p>
		<?php 
    }
    wp_comment_trashnotice();
}

WordPress Version: 5.2

/**
 * Display comments for post.
 *
 * @since 2.8.0
 *
 * @param object $post
 */
function post_comment_meta_box($post)
{
    wp_nonce_field('get-comments', 'add_comment_nonce', false);
    ?>
	<p class="hide-if-no-js" id="add-new-comment"><button type="button" class="button" onclick="window.commentReply && commentReply.addcomment(<?php 
    echo $post->ID;
    ?>);"><?php 
    _e('Add comment');
    ?></button></p>
	<?php 
    $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 '<p id="no-comments">' . __('No comments yet.') . '</p>';
    } else {
        $hidden = get_hidden_meta_boxes(get_current_screen());
        if (!in_array('commentsdiv', $hidden)) {
            ?>
			<script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php 
            echo $total;
            ?>, 10);});</script>
			<?php 
        }
        ?>
		<p class="hide-if-no-js" id="show-comments"><a href="#commentstatusdiv" onclick="commentsBox.load(<?php 
        echo $total;
        ?>);return false;"><?php 
        _e('Show comments');
        ?></a> <span class="spinner"></span></p>
		<?php 
    }
    wp_comment_trashnotice();
}

WordPress Version: 4.4

/**
 * Display comments for post.
 *
 * @since 2.8.0
 *
 * @param object $post
 */
function post_comment_meta_box($post)
{
    wp_nonce_field('get-comments', 'add_comment_nonce', false);
    ?>
	<p class="hide-if-no-js" id="add-new-comment"><a class="button" href="#commentstatusdiv" onclick="window.commentReply && commentReply.addcomment(<?php 
    echo $post->ID;
    ?>);return false;"><?php 
    _e('Add comment');
    ?></a></p>
	<?php 
    $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 '<p id="no-comments">' . __('No comments yet.') . '</p>';
    } else {
        $hidden = get_hidden_meta_boxes(get_current_screen());
        if (!in_array('commentsdiv', $hidden)) {
            ?>
			<script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php 
            echo $total;
            ?>, 10);});</script>
			<?php 
        }
        ?>
		<p class="hide-if-no-js" id="show-comments"><a href="#commentstatusdiv" onclick="commentsBox.load(<?php 
        echo $total;
        ?>);return false;"><?php 
        _e('Show comments');
        ?></a> <span class="spinner"></span></p>
		<?php 
    }
    wp_comment_trashnotice();
}

WordPress Version: 4.0

/**
 * Display comments for post.
 *
 * @since 2.8.0
 *
 * @param object $post
 */
function post_comment_meta_box($post)
{
    wp_nonce_field('get-comments', 'add_comment_nonce', false);
    ?>
	<p class="hide-if-no-js" id="add-new-comment"><a class="button" href="#commentstatusdiv" onclick="window.commentReply && commentReply.addcomment(<?php 
    echo $post->ID;
    ?>);return false;"><?php 
    _e('Add comment');
    ?></a></p>
	<?php 
    $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 '<p id="no-comments">' . __('No comments yet.') . '</p>';
    } else {
        $hidden = get_hidden_meta_boxes(get_current_screen());
        if (!in_array('commentsdiv', $hidden)) {
            ?>
			<script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php 
            echo $total;
            ?>, 10);});</script>
			<?php 
        }
        ?>
		<p class="hide-if-no-js" id="show-comments"><a href="#commentstatusdiv" onclick="commentsBox.get(<?php 
        echo $total;
        ?>);return false;"><?php 
        _e('Show comments');
        ?></a> <span class="spinner"></span></p>
		<?php 
    }
    wp_comment_trashnotice();
}

WordPress Version: 3.9

/**
 * Display comments for post.
 *
 * @since 2.8.0
 *
 * @param object $post
 */
function post_comment_meta_box($post)
{
    global $wpdb;
    wp_nonce_field('get-comments', 'add_comment_nonce', false);
    ?>
	<p class="hide-if-no-js" id="add-new-comment"><a class="button" href="#commentstatusdiv" onclick="window.commentReply && commentReply.addcomment(<?php 
    echo $post->ID;
    ?>);return false;"><?php 
    _e('Add comment');
    ?></a></p>
	<?php 
    $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 '<p id="no-comments">' . __('No comments yet.') . '</p>';
    } else {
        $hidden = get_hidden_meta_boxes(get_current_screen());
        if (!in_array('commentsdiv', $hidden)) {
            ?>
			<script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php 
            echo $total;
            ?>, 10);});</script>
			<?php 
        }
        ?>
		<p class="hide-if-no-js" id="show-comments"><a href="#commentstatusdiv" onclick="commentsBox.get(<?php 
        echo $total;
        ?>);return false;"><?php 
        _e('Show comments');
        ?></a> <span class="spinner"></span></p>
		<?php 
    }
    wp_comment_trashnotice();
}

WordPress Version: 3.8

/**
 * Display comments for post.
 *
 * @since 2.8.0
 *
 * @param object $post
 */
function post_comment_meta_box($post)
{
    global $wpdb;
    wp_nonce_field('get-comments', 'add_comment_nonce', false);
    ?>
	<p class="hide-if-no-js" id="add-new-comment"><a class="button" href="#commentstatusdiv" onclick="commentReply.addcomment(<?php 
    echo $post->ID;
    ?>);return false;"><?php 
    _e('Add comment');
    ?></a></p>
	<?php 
    $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 '<p id="no-comments">' . __('No comments yet.') . '</p>';
    } else {
        $hidden = get_hidden_meta_boxes(get_current_screen());
        if (!in_array('commentsdiv', $hidden)) {
            ?>
			<script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php 
            echo $total;
            ?>, 10);});</script>
			<?php 
        }
        ?>
		<p class="hide-if-no-js" id="show-comments"><a href="#commentstatusdiv" onclick="commentsBox.get(<?php 
        echo $total;
        ?>);return false;"><?php 
        _e('Show comments');
        ?></a> <span class="spinner"></span></p>
		<?php 
    }
    wp_comment_trashnotice();
}

WordPress Version: 3.7

/**
 * Display comments for post.
 *
 * @since 2.8.0
 *
 * @param object $post
 */
function post_comment_meta_box($post)
{
    global $wpdb;
    wp_nonce_field('get-comments', 'add_comment_nonce', false);
    ?>
	<p class="hide-if-no-js" id="add-new-comment"><a href="#commentstatusdiv" onclick="commentReply.addcomment(<?php 
    echo $post->ID;
    ?>);return false;"><?php 
    _e('Add comment');
    ?></a></p>
	<?php 
    $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 '<p id="no-comments">' . __('No comments yet.') . '</p>';
    } else {
        $hidden = get_hidden_meta_boxes(get_current_screen());
        if (!in_array('commentsdiv', $hidden)) {
            ?>
			<script type="text/javascript">jQuery(document).ready(function(){commentsBox.get(<?php 
            echo $total;
            ?>, 10);});</script>
			<?php 
        }
        ?>
		<p class="hide-if-no-js" id="show-comments"><a href="#commentstatusdiv" onclick="commentsBox.get(<?php 
        echo $total;
        ?>);return false;"><?php 
        _e('Show comments');
        ?></a> <span class="spinner"></span></p>
		<?php 
    }
    wp_comment_trashnotice();
}