WordPress酷炫CSS3读者墙,如何弄?自己弄了一下,严重错位!完成之后100分送上!
发布网友
发布时间:2022-05-01 08:20
我来回答
共1个回答
热心网友
时间:2023-10-09 22:55
将如下代码添加到侧边栏文件sidebar.php的对应位置
<h3>最活跃的读者</h3>
<ul>
<?php
$query="SELECT COUNT(comment_ID) AS cnt, comment_author, comment_author_url, comment_author_email FROM (SELECT * FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->posts.ID=$wpdb->comments.comment_post_ID) WHERE comment_date > date_sub( NOW(), INTERVAL 1 MONTH ) AND user_id='0' AND comment_author_email != '' AND post_password='' AND comment_approved='1' AND comment_type='') AS tempcmt GROUP BY comment_author_email ORDER BY cnt DESC LIMIT 15";
$wall = $wpdb->get_results($query);
foreach ($wall as $comment)
{
if( $comment->comment_author_url )
$url = $comment->comment_author_url;
else $url="#";
$r="rel='external nofollow'";
$tmp = "<a href='".$url."' '".$r."' title='".$comment->comment_author." (留下".$comment->cnt."个脚印)'>".get_avatar($comment->comment_author_email, 38)."</a>";
$output .= $tmp;
}
echo $output ;
?>
</ul>
然后再往主题文件style.css添加对应的读者墙css代码
.top_comment ul {}
.top_comment ul li {list-style:none; display:inline;}
.top_comment img.avatar{
width:38px; height:38px;
background:#e3e3e3;
border: 1px solid #e3e3e3;
padding:3px;margin:3px;}
.top_comment img.avatar:hover{background:#d0d0d0;}