Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I would like to reverse the comment pagination numbers so that the newest comments show on page 1 instead of the last page. I did an array_reverse for the comments_array and set the Wordpress Discussion Settings to first page displayed by default - everything works fine except when someone leaves a comment it doesn't take in consideration the array_reverse and it takes the user to the link where the comment would be without the array reverse and obviously the comment is not there.

I noticed that the redirect comes from wp-comments-post.php

$location = empty($_POST['redirect_to']) ? get_comment_link($comment_id) : $_POST['redirect_to'] . '#comment-' . $comment_id;

Is there a way to get the correct redirect link after a comment is submitted? Or is there a simpler way to get the comment pagination numbers reversed? Thanks in advance!

share|improve this question

2 Answers 2

Wouldn't it achievable withing the admin discussion setting page?

Break comments into pages with N top level comments per page and the First/Last page displayed by default. Comments should be displayed with the older/newer comments on the top of each page.

share|improve this answer
    
Yes, but you don't get the newest comments on page 1 - you get them on the last page. And as I mentioned I did a array reverse and that makes them appear on page 1, but then the problem becomes when someone submits a comment they get redirected to the wrong comment page. –  bfszm Jun 15 '12 at 8:46
    
Oh, I never select that option. I thought that it will behave as I expected. But maybe you give a try on get_comments(), instead of using array_reverse, you can give the arguments for get_comments() codex.wordpress.org/Function_Reference/get_comments –  AriePutranto Jun 15 '12 at 23:51

i've used

wp_list_comments

like this:

<?php if (class_exists('Walker_Comment_Wink'))
    $walker = new Walker_Comment_Wink();
  else
    $walker = '';

 wp_list_comments(array('walker' => $walker, 'type' => 'comment' , 'callback' => 'theme_comment2')); ?>

i used the plugin http://winkpress.com/articles/fix-reversed-comments-pagination/ to fix the "* and 1 comment" weirdness.

You have the option to pass

$reverse_top_level (boolean) (optional) Setting this to true will display the most recent comment first then going back in order. Default: null

you can check it in action here http://www.joaoleitao.com/viagens/acerca-do-autor/

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.