Das PlugIn heisst Reverse Order Comments.
Und hier der Code:
<?php
/*
Plugin Name: Reverse Order Comments
Plugin URI: http://www.zyblog.de/2005/11/11/wordpress-plugin-reverse-order-comments/
Description: Allows to display the comments in reverse order. Latest comment first, oldest last.
Author: Tim Zylinski
Version: 1.0
Author URI: http://www.zyblog.de/
*/
// This is a copy of the comments_template() function from wp-includes/comment-functions.php with very little changes.
// Just added the DESC parameter to the SQL queries
function ro_comments_template( $file = '/comments.php' ) {
global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity;
if ( is_single() || is_page() || $withcomments ) :
$req = get_settings('require_name_email');
$comment_author = isset($_COOKIE['comment_author_'.COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_'.COOKIEHASH])) : '';
$comment_author_email = isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_email_'.COOKIEHASH])) : '';
$comment_author_url = isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_url_'.COOKIEHASH])) : '';
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");
} else {
$author_db = addslashes($comment_author);
$email_db = addslashes($comment_author_email);
$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");
}
get_currentuserinfo();
define('RO_COMMENTS_TEMPLATE', true);
$include = apply_filters('comments_template', TEMPLATEPATH . $file );
if ( file_exists( $include ) )
require( $include );
else
require( ABSPATH . 'wp-content/themes/default/comments.php');
endif;
}
?>
Alles anzeigen