Hallo,
ich habe da auch mal eine Frage zur Ausgabe der letzten Kommentare. Aus irgend einem Grund funktionierte bei mir das Plugin "Get-Recent-Comments" nicht mehr. Also habe ich gegoogelt und einen passenden Code gefunden.
Soweit konnte ich diesen auch anpassen aber ich weiß leider nicht, wie ich meine eigenen Kommentare hier ausschließen kann ... Die Ausgabe erfolgt in der Sidebar.php.
Es wäre toll, wenn mir hier jemand helfen könnte ... Vielen Dank im Voraus :)
PHP
<!-- Letzte Kommentare -->
<!-- Suche die letzten 10 vom Typ Comment die akzeptiert wurden und sortiere es nach Datum absteigend -->
<?php $comments = $wpdb->get_results("SELECT comment_post_ID, comment_author, comment_author_email, comment_content, comment_date
FROM $wpdb->comments
WHERE comment_type = ''
&& comment_approved = '1'
ORDER BY comment_date DESC LIMIT 5"); ?>
<!-- ab hier der Ausgabeteil -->
<ul>
<?php $commenttype = 'even';
foreach($comments as $comment) {
$post = get_postdata($comment->comment_post_ID); ?>
<table width="100%" border="0" cellpadding="0" cellspacing="2">
<tr>
<td>
<table width="100%" border="0" cellpadding="0" cellspacing="2">
<tr>
<td width="50" align="left" valign="top"><ul>
<div class="comment-gravatar-sidebar"><?php $gravatar_url = "http://www.gravatar.com/avatar.php?gravatar_id=" . md5(get_comment_author_email()) . "&default=" . urlencode($gravatar_default) . "&size=70"; ?>
<img class="comment-gravatar-sidebar" src="<?php echo $gravatar_url ?>" alt="Gravatar of <?php comment_author() ?>" />
</td>
<td align="left" valign="middle"><b><font size="1"><?php echo $comment->comment_author; ?></font></b><br><b><font size="1"><?php comment_date('j. M Y'); ?></font></b> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="text-align: bottom"><font size="1"> <p align="justify"><?php
echo wp_html_excerpt( $comment->comment_content, 150 ); ?>..."
<a href="<?php echo get_permalink($comment->comment_post_ID); ?>"
rel="external nofollow" title="<?php echo $title; ?>">
<?php echo $title; ?></font></p> </a>
</li>
</td>
</tr>
</table>
<br> <?php if($commenttype == "even") { $commenttype = "odd"; } else { $commenttype = "even"; } ?>
<?php } ?>
</ul>
<!-- Ende Letzte Kommentare -->
Alles anzeigen