已经纠结了一段时间了,一直找不到一种比较好的方式来添加分享按钮,试过sexybookmarks,还有他的中文版(网友改),虽然这个插件的显示效果不错,但因为其实在不符合中国国情,而且可定制性不强终究还是放弃了。
最终在看了网上的一篇资料后摸索着用非插件的形式添加了些许分享按钮,不敢独享,拿出来大家参详参详。
步骤如下:
1、打开themes下自己的主题文件夹,选择single.php
找到:
<?php the_content(__('Read more', 'monochrome')); ?>
在其后插入:
<div>
<h2><span style="color: #ff6600;"><strong><em>Share is amazing~~</em></strong></span></h2>
</div>
<div>
<a href="javascript:var u='http://www.douban.com/recommend/?url='+location.href+'&title='+encodeURIComponent(document.title);window.open(u,'douban','toolbar=0,resizable=1,scrollbars=yes,status=1,width=450,height=330');void(0)" title="douban"><img src="<?php bloginfo('template_url'); ?>/icon/douban.gif" /></a>
<a href="javascript:var%20b=document.body;var%20GR________bookmarklet_domain='http://www.google.com';if(b&&!document.xmlVersion){void(z=document.createElement('script'));void(z.src='http://www.google.com/reader/ui/link-bookmarklet.js');void(b.appendChild(z));}else{}" title="Share in Google Reader" rel="nofollow"><img src="<?php bloginfo('template_url'); ?>/icon/google.gif" alt="分享到 Google Reader" /></a>
<a href="javascript:u='http://share.xiaonei.com/share/buttonshare.do?link='+location.href+'&title='+encodeURIComponent(document.title);window.open(u,'xiaonei','toolbar=0,resizable=1,scrollbars=yes,status=1,width=626,height=436');void(0)" title="renren"><img src="<?php bloginfo('template_url'); ?>/icon/renren.gif" /></a>
<a href="javascript:var u='http://www.kaixin001.com/~repaste/repaste.php';window.open(u,'kaixin');void(0)" title="kaixin"><img src="<?php bloginfo('template_url'); ?>/icon/kaixin.gif" /></a>
<a href="javascript:window.open('http://shuqian.qq.com/post?from=3&title='+encodeURIComponent(document.title)+'&uri='+encodeURIComponent(location.href)+'&jumpback=2&noui=1','favit','width=930,height=470,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes');void(0)" title="QQ"><img src="<?php bloginfo('template_url'); ?>/icon/QQshuqian.gif" /></a>
<a href="javascript:u=location.href;t=document.title;c = '' + (window.getSelection ? window.getSelection() : document.getSelection ? document.getSelection() : document.selection.createRange().text);var url='http://cang.baidu.com/do/add?it='+encodeURIComponent(t)+'&iu='+encodeURIComponent(u)+'&dc='+encodeURIComponent(c)+'&fr=ien#nw=1';window.open(url,'_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes'); void 0" title="baidu"><img src="<?php bloginfo('template_url'); ?>/icon/baidu.gif" /></a>
<a target="_blank" href="http://www.facebook.com/share.php?u="+location.href+"&t="+encodeURIComponent(document.title)" title="Facebook"><img src="<?php bloginfo('template_url'); ?>/icon/facebook.gif" /></a>
<a href="javascript:var u='http://twitter.com/home?status='+encodeURIComponent('我正在看:'+encodeURIComponent(document.title)+'( '+location.href+' )');window.open(u,'twitter');void(0)" title="twitter"><img src="<?php bloginfo('template_url'); ?>/icon/twitter.gif" /></a>
<a target="_blank" href="http://del.icio.us/post?url="+location.href+"&title="+encodeURIComponent(document.title)" title="Del.icio.us"><img src="<?php bloginfo('template_url'); ?>/icon/delicious.gif"/></a>
</div>
保存
2、在同一文件夹下新建icon文件夹,下载图标到保存到该文件夹下。下载地址:uushare
ok,可以看到效果啦~
不太复杂吧,这里的图标都放在自己的主机上了,可以加快加载的速度。
不足:不知道为什么title这个字段用中文总是乱码,不得已,只能换上英文字母,谁有解决方法的敬请指导。
下一步计划修改的部分:添加鲜果推荐及其他符合中国特点的代码。而对于twitter、facebook之类国内用得不多,还是去掉比较合适,为将来者腾出空间。
——-分割线——-
感谢mrlee的回复,只要另存为utf-8就可以避免乱码了,Cool~
——-分割线——-
参考资料: