Rearanjarea comentariilor pe WordPress
Postat de Cristian Doiu in
March 22, 2008
Uite chiar ma gandeam acum cateva zile pentru ca vedeam pe anumite bloguri pagina de commenturi “rasturnata”. Ma gandeam eu ca e ceva simplu si nu e cine stie ce… pana cand am inceput sa ma interesez pe net. Daca vreti sa apara ultimul comentariu primu ( e foarte bun pentru sporirea comentariilor si promovarea userilor ) faceti urmatorul lucru:
Intra in /wp-includes/comment-template.php acolo veti gasi urmatorul cod ( mai exact pe linia 290 in Dreamwaver ) :
// TODO: Use API instead of SELECTs.
if ( $user_ID) {
$comments = $wpdb->get_results(”SELECT * FROM $wpdb->comments WHERE comment_post_ID = ‘$post->ID’ AND (comment_approved = ‘1′ OR ( user_id = ‘$user_ID’ AND comment_approved = ‘0′ ) ) ORDER BY comment_date”);
} else 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”);
} else {
$author_db = $wpdb->escape($comment_author);
$email_db = $wpdb->escape($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”);
}
Dupa ce l-ati gasit nu trebuie decat sa adaugati cateva litere: DESC
Inlocuiti codul de mai sus cu urmatorul cod:
// TODO: Use API instead of SELECTs.
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 = $wpdb->escape($comment_author);
$email_db = $wpdb->escape($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“);
}







One Response to “Rearanjarea comentariilor pe WordPress”
desigur, modificari in core wordpress files. real smart, update wise.
p.s. cauta mai bine ca exista pluginuri pentru asa ceva.
By SlimR on Mar 24, 2008