This is a related_comments.php file which should display comments on certain pages in ascending order while the newest comment should be at the top.

This is working fine if there is only one page for the comments, but not if the comments are split across multiple pages.

On a second comment page, there appear comments with a newer date than the oldest comments on the bottom of the first page. Why is that and how can I fix it?

It seems the comments get ordered when they are received but not when displayed on the frontend. How can I change it so it sorts correctly across multiple pages?

//static guestbook page
$guestbookPageId = 141;

global $comments;
$comments = get_comments(array(
        'post_id' => $guestbookPageId,
        'status' => 'approve',
        'order' => 'ASC',
        'meta_query' => array(
            'relation' => 'OR',
                'key'   => 'page_relation',
                'value' => get_the_ID()
                'key'   => 'page_relation_2',
                'value' => get_the_ID()
                'key'   => 'page_relation_3',
                'value' => get_the_ID()

if(!$comments || empty($comments) || count($comments) < 1)

<div id="comments" class="comments-area">

<div class="comment-list">
        wp_list_comments( array(
            'style'      => 'div',
            'callback' => 'amakido_comment',
        ), $comments);

<?php if ( get_comment_pages_count($comments) > 1 && get_option(         'page_comments' ) ) : // are there comments to navigate through ?>
<nav id="comment-nav-below" class="comment-navigation" role="navigation">
    <?php paginate_comments_links(); ?>

<?php endif; // check for comment navigation ?>


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.