Fill last page of comments

  1. jumbo

    The following seems to work to fill the default, canonical page with a full set of comments. Tested with WordPress version 5.0.3. A big portion of the fix comes from the following trac comment:

    Put the following in your functions.php file, but be sure to read the inline comments as you'll also have to make a change to the wp_list_comments() function within your 'comments.php' file.

     * Reverse comments pagination.
     * Step 1:
     * WordPress Admin Settings > Discussion Settings:
     * Break comments into pages with [NUMBER] top level comments per page and the [FIRST] page displayed by default
     * Comments should be displayed with the [OLDER] comments at the top of each page
     * Step 2:
     * The following settings should be applied in your 'comments.php' template's 'wp_list_comments()' function.
     * wp_list_comments(
     *     [
     *         'reverse_top_level' => true, // Reverse the comment order to show oldest on top to newest on bottom.
     *         'reverse_children'  => true, // So that threaded child comments appear oldest to newest.
     *     ]
     * );
     * @link   https://core.trac.wordpress.org/ticket/29462#comment:28
     * @since  WordPress 5.0.3
     * @param  array $comment_args Array of WP_Comment_Query arguments.
     * @return array
    function reverse_comments_pagination( $comment_args ) {
        $comment_args['order'] = 'DESC';
        return $comment_args;
    add_filter( 'comments_template_query_args', 'reverse_comments_pagination' );
    Posted: 1 year ago #

RSS feed for this topic


You must log in to post.

  • Rating

    9 Votes
  • Status

    This idea is under consideration