给wordpress友情链接页面添加Favicon图标
发表时间:2012-3-29 评论:0 点击 2,883+
1、先看看自己主题header部分是否有加载jQuery库,如果加载了就不必加载了,如果没加载就在header.php文件的head部分加载如下代码。
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
2、加载jQuery库后,再在</head>之前添加下面的代码
<;script type="text/javascript">
jQuery(document).ready(function($){
$(".link_page ul li a").each(function(e){
$(this).prepend("<img src=http://www.google.com/s2/favicons?domain="+this.href.replace(/^(http:\/\/[^\/]+).*$/, '$1').replace( 'http://', '' )+" style=float:left;padding:2px;>");
});
});
</script>
说明:.link_page ul li a需要自己修改友链标题的class属性位置,一直要到a标记。