• Cory.Nickerson

    (@corynickerson)


    I’ve noticed there is a problem when you set the sorting order on comments to newest so it displays the most recent comments first, it still breaks them into pages based on oldest comments first.

    For example if you had 10 comments per page and there are 13 comments total.

    When displaying oldest comments first it will display them as this:

    Page 1: 1 2 3 4 5 6 7 8 9 10
    Page 2: 11 12 13

    When displaying newest comments first it will display them like this:

    Page 1: 13 12 11
    Page 2: 10 9 8 7 6 5 4 3 2 1

    As you can see it displays them in descending order with newest comments first. However it is putting only 3 comments on “Page 1” and then 10 comments on “Page 2”.

    It should display like this:

    Page 1: 13 12 11 10 9 8 7 6 5 4
    Page 2: 3 2 1

    Is there any solution to this? Seems like a problem with sorting the results in the MySQL query.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator t-p

    (@t-p)

    what theme are you using?

    Thread Starter Cory.Nickerson

    (@corynickerson)

    Tara,

    I am coding my own theme. I am using the default wp_list_comments() function.

    Thread Starter Cory.Nickerson

    (@corynickerson)

    comments.php

    <?php if ( have_comments() ) : ?>
    <ol class="commentlist">
    	<?php
    		wp_list_comments(
    			array (
    				'type'					=> 'comment',
    				'callback'				=> 'yyz_custom_comments'
    			)
    		);
    	?>
    </ol>
    <?php endif; ?>

    functions.php

    // Custom comments template.
    function yyz_custom_comments() {
    
    	include( 'comments-single.php' );
    }

    comments-single.php

    <li id="comment-<?php echo get_comment_ID(); ?>">
    	<div class="comment-avatar">
    		<?php echo get_avatar( $GLOBALS['comment'], 48 ); ?>
    	</div>
    	<div class="comment-meta">
    		<strong><?php echo get_comment_author_link(); ?></strong> •
    		<a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>"><?php echo get_comment_date(); ?> <?php echo get_comment_time(); ?></a>
    		<?php edit_comment_link( __( '(Edit)' ), '  ', '' ); ?>
    	</div>
    	<div class="comment-content">
    		<?php comment_text(); ?>
    	</div>
    	<div class="comment-bottom">
    		<?php
    			$post_id = get_the_ID();
    			$comment_id = get_comment_ID();
    
    			$max_depth = get_option('thread_comments_depth');
    
    			$default = array(
    				'add_below'  => 'comment',
    				'respond_id' => 'respond',
    				'reply_text' => __('Reply'),
    				'login_text' => __('Log in to Reply'),
    				'depth'      => 1,
    				'before'     => '',
    				'after'      => '',
    				'max_depth'  => $max_depth
    			);
    
    			comment_reply_link( $default, $comment_id, $post_id );
    		?>
    	</div>
    </li>

    Thread Starter Cory.Nickerson

    (@corynickerson)

    Is this posted in the correct forum?

    Thread Starter Cory.Nickerson

    (@corynickerson)

    It appears this flaw is in every theme. Its coded flawed. You cannot create results in descending order from newest post time. All you can do is make newer pages display first.

    Comment system was badly planned out. Guess I will have to do a re-write with a custom query to the DB to sort this out.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Problem displaying newest comments’ is closed to new replies.