让免插件读者墙在IE下显示留言者名字

知更鸟
知更鸟
知更鸟
站长
2511
文章
0
粉丝
WordPress6,842阅读模式
摘要  这段免插件读者墙代码原型,确实无此功能,之前改过,后来忘记加了,因为很少用IE看自己的博客,有人提议加上,就改了一下,愿意折腾的可以按下面方法修改。   主题中添加的免插件读者...

这段免插件读者墙代码原型,确实无此功能,之前改过,后来忘记加了,因为很少用IE看自己的博客,有人提议加上,就改了一下,愿意折腾的可以按下面方法修改:
主题中添加的免插件读者墙代码在原型基础上稍作修改添加了external nofollow属性,原出处未知:

  1. <?php
  2. $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 10";
  3. $wall = $wpdb->get_results($query);
  4. foreach ($wall as $comment)
  5. {
  6. if( $comment->comment_author_url )
  7. $url = $comment->comment_author_url;
  8. else $url="#";
  9. $r="rel='external nofollow'";
  10. $tmp = "<a href='".$url."' '".$r."' title='".$comment->comment_author." (留下".$comment->cnt."个脚印)'>".get_avatar($comment->comment_author_email, 32)."</a>";
  11. $output .= $tmp;
  12. }
  13. echo $output ;
  14. ?>

上面代码,未针对IE添加atl属性,参考了一下别人的修改方法,改为:

  1. <?php
  2. $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 10";
  3. $wall = $wpdb->get_results($query);
  4. foreach ($wall as $comment)
  5. {
  6. if( $comment->comment_author_url )
  7. $url = $comment->comment_author_url;
  8. else $url="#";
  9. $r="rel='external nofollow'";
  10. $imgsize="32";
  11. $tmp = "<a target='_blank' href='".$url."' title='".$comment->comment_author." (留下".$comment->cnt."个脚印)'><img width='".$imgsize ."' height='".$imgsize ."' src='http://www.gravatar.com/avatar.php?gravatar_id=".md5( strtolower($comment->comment_author_email) )."&size=".$imgsize ."&d=identicon&r=G' alt='".$comment->comment_author."(留下".$comment->cnt."个脚印)' /></a>";
  12. $output .= $tmp;
  13. }
  14. echo $output ;
  15. ?>

具体针对热点新闻2.4版主题修改方法:

打开:top_comment.php及Message.php

找到:

  1. $tmp = "<a href='".$url."' '".$r."' title='".$comment->comment_author." (留下".$comment->cnt."个脚印)'>".get_avatar($comment->comment_author_email, 32)."</a>";

替换为:

  1. $imgsize="32";
  2. $tmp = "<a target='_blank' href='".$url."' title='".$comment->comment_author." (留下".$comment->cnt."个脚印)'><img width='".$imgsize ."' height='".$imgsize ."' src='http://www.gravatar.com/avatar.php?gravatar_id=".md5( strtolower($comment->comment_author_email) )."&size=".$imgsize ."&d=identicon&r=G' alt='".$comment->comment_author."(留下".$comment->cnt."个脚印)' /></a>";

我的已改,可以看看效果

本站文章大部分为原创,用于个人学习记录,可能对您有所帮助,仅供参考!

weinxin
我的微信
微信号已复制
版权声明
本站原创文章转载请注明文章出处及链接,谢谢合作!
 
评论  30  访客  22  作者  7