/** * Define widget. */ function wp_widget_recentcomments($args) { if ('%BEG_OF_TITLE%' != $args['before_title']) { if ($output = wp_cache_get('widget_recentcomments', 'widget')) { return print $output; } ob_start(); } extract($args); $options = get_option('widget_recentcomments'); $title = empty($options['title']) ? __('Recent Comments', 'wp-recentcomments') : $options['title']; echo $before_widget; echo $before_title . $title . $after_title; echo '<ul>'; wp_recentcomments(); echo '</ul>'; echo $after_widget; if ('%BEG_OF_TITLE%' != $args['before_title']) { wp_cache_add('widget_recentcomments', ob_get_flush(), 'widget'); } }
</div> </div> <div class="side_block"> <div class="side_mid"> <?php if (function_exists('wp_recentcomments')) { ?> <h3><?php echo _e("New comments", "lighterblue"); ?> </h3> <ul> <?php wp_recentcomments('limit=10&length=16&post=false&smilies=true&administrator=false'); ?> </ul> <?php } else { ?> <?php echo _e("<h3>New comments</h3>", "lighterblue"); ?> <?php // 不显示管理员评论方法 将 $sql 倒数第一行中的 admin 改为自己的用户名 global $wpdb; $sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved,comment_author_email, comment_type,comment_author_url, SUBSTRING(comment_content,1,25) AS com_excerpt FROM {$wpdb->comments} LEFT OUTER JOIN {$wpdb->posts} ON ({$wpdb->comments}.comment_post_ID = {$wpdb->posts}.ID) WHERE comment_approved = '1' AND comment_type = '' AND comment_author != 'admin' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT 10"; $comments = $wpdb->get_results($sql); $output = $pre_HTML; foreach ($comments as $comment) {
echo '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>'; } $post = $posts[0]; ?> </ul> </div> <!-- recent comments --> <?php if (function_exists('wp_recentcomments')) { ?> <div class="widget"> <h3>Recent Comments</h3> <ul> <?php wp_recentcomments('limit=5&length=16&post=false&smilies=true'); ?> </ul> </div> <?php } ?> <!-- tag cloud --> <?php if (!is_single()) { ?> <div id="tag_cloud" class="widget"> <h3>Tag Cloud</h3> <?php wp_tag_cloud('smallest=8&largest=16');
<?php } $post = $posts[0]; ?> </ul> </div> <!-- recent comments --> <?php if (function_exists('wp_recentcomments')) { ?> <div class="widget"> <h3>Recent Comments</h3> <ul> <?php wp_recentcomments('limit=5&length=15&pingback=false&trackback=false&post=false&avatar_position=right'); ?> </ul> </div> <?php } ?> <!-- tag cloud --> <div class="widget widget_tag_cloud"> <h3>Tag Cloud</h3> <?php wp_tag_cloud('smallest=8&largest=16'); ?> </div>