WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] chanching the way comment are listed (4 posts)

  1. Matje
    Member
    Posted 8 years ago #

    I'd like to change the order of the comments, not like this
    1.
    2.
    3.
    etc.

    but the newer post on the top! like this
    3.
    2.
    1.

    in what php file do i have to change something and what do I have to change??

    Matje

  2. Mark (podz)
    Support Maven
    Posted 8 years ago #

    Descending Comments
    File: /wp-includes/comment-functions.php

    Line 13
    if ( empty($comment_author) ) {
    $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_approved = '1' ORDER BY comment_date DESC");

    See the DESC at the end ? Add that.

    Line 18
    $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND ( comment_approved = '1' OR ( comment_author = '$author_db' AND comment_author_email = '$email_db' AND comment_approved = '0' ) ) ORDER BY comment_date DESC");
    See the DESC at the end of this line ? Add that too.

    That's it.

    This is a core change, so remember it.
    (Above applies to wp2.x)

  3. Truth
    Member
    Posted 8 years ago #

    http://wordpress.org/support/topic/38145?replies=10#post-331645

    might help for the comments number too :)

    // Do not have to worry about the core file when upgrading too because the change is in the themes file..

  4. Matje
    Member
    Posted 8 years ago #

    yeah mean, it works!!! super work.
    thank you very much podz
    Matje

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags