下面是一个在我的主页上显示最新4条批准评论的功能,这是我差不多一年前写的,在我的一生中,它完全从我的脑海中消失了,我只想在评论所在的位置添加一个永久链接。如何添加,以及在何处添加?
function showLatestComments() {
global $wpdb;
$sql = "
SELECT DISTINCT comment_post_ID, comment_author, comment_date_gmt, comment_approved, SUBSTRING(comment_content,1,100) AS com_excerpt
FROM $wpdb->comments
WHERE comment_approved = \'1\'
ORDER BY comment_date_gmt DESC
LIMIT 4";
$comments = $wpdb->get_results($sql);
$output .= \'<img src="/wp-content/themes/blue-and-grey/images/student-perspectives.jpg" /><h2>Latest student perspectives</h2>
<ul id="comm">\';
foreach ($comments as $comment) {
$output .= \'<li><strong>\'. $comment->comment_author . \' said</strong> : "\' . strip_tags($comment->com_excerpt). \'..."</li>\';
}
$output .= \'</ul>\';
echo $output;
}
//end function