最近浏览源代码文件位子,\pages\template-mostactive.php
核心代码
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<div class="comment-authors">
<?php the_content(); ?>
</div>
<?php endwhile; ?>
<?php top_comments(98); ?>
<div class="clear"></div>
</main>
</div>
其实真正的核心代码不是在这里的,里面的 <?php top_comments(98); ?> 这才是核心文件,位子\inc\inc.php
代码:
function top_comments($number = 98) {
global $wpdb;
$counts = wp_cache_get( 'mostactive' );
if ( false === $counts ) {
$counts = $wpdb->get_results("SELECT COUNT(comment_author) AS cnt, comment_author, comment_author_url, comment_author_email
FROM {$wpdb->prefix}comments
WHERE comment_date > date_sub( NOW(), INTERVAL 90 DAY )
AND comment_approved = '1'
AND comment_author_email != 'example@example.com'
AND comment_author_email != ''
AND comment_type = ''
AND user_id = '0'
GROUP BY comment_author_email
ORDER BY cnt DESC
LIMIT $number");
}
$mostactive = '<div class="top-comments">';
if ( $counts ) {
wp_cache_set( 'mostactive', $counts );
foreach ($counts as $count) {
$c_url = $count->comment_author_url;
$mostactive .= '
<div class="lx8">
<div class="top-author">
<div class="top-comment"><a href="' . get_template_directory_uri()."/inc/go.php?url=". $c_url . '" target="_blank" rel="external nofollow">' . get_avatar($count->comment_author_email, 96). '<div class="author-url"><strong> ' . $count->comment_author . '</div></strong></a></div>
<div class="top-comment">'.$count->cnt.'个脚印</div>
</div>
</div>';
}
$mostactive .= '<div class="clear"></div></div>';
echo $mostactive;
}
}
if (zm_get_option('meta_delete')) {
} else {
require get_template_directory() . '/inc/meta-delete.php';
}
上图我标出来是主要条件,比如我为了让我的最近读者显示更人性化,我就只删掉了URL网站一个条件。关于其他的条件可以根据我截图的SQL代码进行修改的。
历史上的今天
- 2018: C++程序设计,课程代码4737,课后习题6答案(1)
- 2018: 我也不知道这个叫什么,自己比较喜欢。(4)
欢迎来到菜鸟头头的个人博客,下方有我的微信二维码,对互联网感兴趣或有共同爱好的朋友,可加个好友一起交流学习。
本文章百度已收录,若发现本站有任何侵犯您利益的内容,请及时邮件或留言联系,我会第一时间删除所有相关内容。