给wordpress友情链接页面添加Favicon图标

1、先看看自己主题header部分是否有加载jQuery库,如果加载了就不必加载了,如果没加载就在header.php文件的head部分加载如下代码。

1
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>

2、加载jQuery库后,再在之前添加下面的代码

1
<;script type="text/javascript">
1
jQuery(document).ready(function($){ 
1
$(".link_page ul li a").each(function(e){
1
$(this).prepend("<img src=http://www.google.com/s2/favicons?domain="+this.href.replace(/^(http:\/\/[^\/]+).*$/, '$1').replace( 'http://', '' )+" style=float:left;padding:2px;>");
1
}); 
1
});
1
</script>

说明:.link_page ul li a需要自己修改友链标题的class属性位置,一直要到a标记。