Hallo zusammen!
Ich habe mir eine auf Basis eines anderen Funktions-Codes eine Top-Kommentator-Anzeige für die letzten 365 und die letzten 30 Tage zusammengebaut.
Die sieht - für die Anzeige der letzten 12 Monate - wie folgt aus:
PHP
function top_commentators_jahr() {
global $wpdb;
$topcommentator_query="SELECT comment_author, comment_author_email, comment_type, SUBSTRING_INDEX(comment_author_url, '/', 3) as top_commentator, COUNT(*) as top_num FROM $wpdb->comments
WHERE comment_approved='1'
AND comment_author_email NOT LIKE 'xyz@domain.de%'
AND comment_author_email NOT LIKE 'abc@domain.de%'
AND comment_type NOT LIKE 'pingback' OR 'trackback'
AND comment_date >= CURDATE() - INTERVAL 365 DAY
GROUP BY top_commentator
Order by top_num DESC, comment_date ASC
LIMIT 3";
$topcommentator_result = $wpdb->get_results($topcommentator_query);
if ( !empty($topcommentator_result) ) {
echo '<ol>';
foreach ($topcommentator_result as $comment) :
$co_aut = $comment->top_commentator;
$co_aut = str_ireplace("http://", "", $co_aut);
echo '<li>',get_avatar( $comment, 32 ),' <a href="'.$comment->top_commentator.'/" target="_blank">'.$comment->comment_author.'</a> ('.$comment->top_num.') </li>';
echo '<br /><br /><br />';
endforeach;
echo '</ol>';
}
}
Alles anzeigen
Wenn ich mir die jetzt für die Anzeige der letzten 30 Tage kopieren will, dafür im Funktionsnamen das 'jahr' durch 'monat' ersetze und bei den Tagen die 365 durch 30, dann zeigt er mir die selbe Ansicht wie bei der für das Jahr an.
Anschauen könnt ihr Euch das hier
Der Funktionsaufruf sieht wie folgt aus:
PHP
<?php if ( is_home() || is_single() ) { ?>
<div class="box2">
<h5>Top Kommentatoren der letzten 30 Tage</h5>
<?php echo top_commentators_monat(); ?><br />
<h5>Top Kommentatoren der letzten 365 Tage</h5>
<?php echo top_commentators_jahr(); ?>
</div>
Ich habe vor diesen Funktionsaufruf sogar noch ein
gesetzt, was jedoch erfolglos blieb.
Jemand eine Idee, woran das liegen könnte?
Danke im voraus!
Marcus