Hallo,
ich hab mir das ecent_comments Plugin installiert und es funktioniert auch wunderbar. Allerdings bin ich absoluter PHP-Laie und würde gern wissen, wie ich es anstelle, das anstelle des Namens des Kommentierers (klasse Wortschöpfung) und einem Auszug aus dem Kommentar der Name und der Titel des Posts, auf den er sich bezieht in der Sidebar auftaucht.
Das Blog könnt Ihr unter http://www.kraxler.com anschauen, die recent-comments.php sieht folgendermaßen aus:
PHP
<?php
/*
Plugin Name: Recent Comments
Plugin URI: http://mtdewvirus.com/code/wordpress-plugins/
Description: Retrieves a list of the most recent comments.
Version: 1.16
Author: Nick Momrik
Author URI: http://mtdewvirus.com/
*/
function mdv_recent_comments($no_comments = 10, $comment_lenth = 10, $before = '[*]', $after = '', $show_pass_post = false, $comment_style = 0) {
global $wpdb;
$request = "SELECT ID, comment_ID, comment_content, comment_author, post_title FROM $wpdb->comments LEFT JOIN $wpdb->posts ON $wpdb->posts.ID=$wpdb->comments.comment_post_ID WHERE post_status = 'publish' ";
if(!$show_pass_post) $request .= "AND post_password ='' ";
$request .= "AND comment_approved = '1' ORDER BY comment_ID DESC LIMIT $no_comments";
$comments = $wpdb->get_results($request);
$output = '';
if ($comments) {
foreach ($comments as $comment) {
$comment_author = stripslashes($comment->comment_author);
if ($comment_author == "")
$comment_author = "anonymous";
$comment_content = strip_tags($comment->comment_content);
$comment_content = stripslashes($comment_content);
$words=split(" ",$comment_content);
$comment_excerpt = join(" ",array_slice($words,0,$comment_lenth));
$permalink = get_permalink($comment->ID)."#comment-".$comment->comment_ID;
if ($comment_style == 1) {
$post_title = stripslashes($comment->post_title);
$output .= $before . comment_author_link() . ' on ' . $post_title . '.' . $after;
}
else {
$output .= $before . '' . $comment_author . ': <a href="' . $permalink;
$output .= '" title="Mehr von ' . $comment_author.' lesen">' . $comment_excerpt.'</a>' . $after;
}
}
$output = convert_smilies($output);
} else {
$output .= $before . "Noch kein Echo" . $after;
}
echo $output;
}
?>
Alles anzeigen
Aufgerufen werden die Kommentare mit <?php mdv_recent_comments(); ?>
Für jede Hilfe dankbar wünscht Euch ein schönes Wochenende
der Kraxler