Puoi filtrare i commenti in WordPress per mostrare l'utente con più commenti con conteggio, email, URL autore, ecc.
Istruzioni: Aggiungi il seguente codice al file functions.php del tuo tema WordPress.
Usa $result->comment_author_email, $result->comments_count, $result->comment_author_url, per aggiungere parametri aggiuntivi a questo codice.
function top_comment_authors($amount = 5) {
global $wpdb;
$results = $wpdb->get_results('
SELECT
COUNT(comment_author_email) AS comments_count, comment_author_email, comment_author, comment_author_url
FROM '.$wpdb->comments.'
WHERE comment_author_email != "" AND comment_type = "" AND comment_approved = 1
GROUP BY comment_author_email
ORDER BY comments_count DESC, comment_author ASC
LIMIT '.$amount
);
$output = "<ul>";
foreach($results as $result) {
$output .= "<li>".$result->comment_author."</li>";
}
$output .= "</ul>";
echo $output;
}
Usa semplicemente questo codice nei tuoi file di template per mostrare l'utente con più commenti.
<? top_comment_authors(); ?>
Potrebbe interessarti anche abilitare i commenti nidificati in WordPress.
Come posso mostrare solo l'utente con più commenti di un mese? non tutto il tempo solo un mese
esattamente stavo cercando questo codice. l'hai fatto per me 🙂 grazie è stato utile per il mio nuovo tema.