参考源自文章:https://blog.csdn.net/shuzui1985/article/details/39212177
首先在主题根目录下创建一个名为share.php的文件,内容如下:
<?php
//shareto.php
$permalink = urlencode(get_permalink($post->ID));
$title = urlencode($post->post_title);
$title = str_replace('+','%20',$title);
?>
<div>
<a title="新浪微博" rel="nofollow" href="https://service.weibo.com/share/share.php?url=<?php echo $permalink; ?>&title=<?php echo $title; ?>&content=utf-8" target="_blank">
<img title="分享到新浪微博" src="images/sina.png" alt="新浪微博" height="35" width="35"/>
</a>
<a title="QQ空间" rel="nofollow" href="http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=<?php echo $permalink; ?>&title=<?php echo $title; ?>&content=utf-8" target="_blank">
<img title="分享到QQ空间" src="images/qzone.png" alt="QQ空间" height="35" width="35"/>
</a>
<a href="http://shuo.douban.com/!service/share?href=<?php echo $permalink; ?>&title=<?php echo $title; ?>&sel=&v=1" target="_blank" rel="nofollow">
<img title="分享到豆瓣" src="images/douban.png" alt="豆瓣" height="35" width="35"/>
</a>
<a title="百度贴吧" rel="nofollow" href="http://tieba.baidu.com/i/app/open_share_api?link=<?php echo $permalink; ?>&source=<?php echo get_bloginfo('name'); ?>&title=<?php echo $title; ?>&content=utf-8" target="_blank">
<img title="分享到百度贴吧" src="images/tieba.png" alt="百度贴吧" height="35" width="35"/>
</a>
<a title="QQ" rel="nofollow" href="http://connect.qq.com/widget/shareqq/index.html?url=<?php echo $title; ?>%20-%20<?php echo $permalink; ?>" target="_blank">
<img title="分享到QQ" src="images/qq.png" alt="QQ" height="35" width="35"/>
</a>
<p></p>
</div>
然后根据需要在 single.php 中的某一位置加入如下代码即可:
<?php include(TEMPLATEPATH."/share.php");?>