wordpress博客添加微博、微信分享等等

参考:

http://icyou.org/1185

http://icyou.org/385

在使用WordPress过程中,有时为了方便阅读着分享到主流的社交网站或微薄,需要在文章旁边添加一些分享按钮。

修改步骤如下:

PS: 把下载好的images下面的图标文件上传到你的空间中。

一 :把写好的 share.php 上传到你的主题目录,然后把其中的图片的地址改为你自己上传的 如: /wp-content/themes/你的主题名字/ 下面:

<?php
//shareto.php
$permalink = urlencode(get_permalink($post->ID));
$title = urlencode($post->post_title);
$title = str_replace(‘+’,’%20′,$title);

$sitename=”jimlung”;

$domainurl=”http://icyou.org/”;
//把下面的图片url替换成自己的空间的url
?>

<div>
<span>我要分享到:</span>
<a title=”新浪微博” rel=”nofollow” href=”http://v.t.sina.com.cn/share/share.php?url=<?php echo $permalink; ?>&title=<?php echo $title; ?>&content=utf-8″ target=”_blank”><img title=”新浪微博” src=”images/sina.png” alt=”新浪微博” /></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/qq.png” alt=”QQ空间” /></a>
<a title=”腾讯微博” rel=”nofollow” target=”_blank” href=”javascript:window.open(‘http://v.t.qq.com/share/share.php?title=’+’<?php echo $title; ?>’+encodeURIComponent(document.title)+’&url=’+encodeURIComponent(‘<?php echo $permalink; ?>’)+’&jumpback=2&noui=1′,’favit’,’width=700,height=546,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes’);void(0)” ><img title=”腾讯微博” src=”images/tqq.png” alt=”腾讯微博” /></a>
<a href=”http://www.douban.com/recommend/?url=<?php echo $permalink; ?>&amp;title=<?php echo $title; ?>&amp;sel=&amp;v=1″ target=”_blank” rel=”nofollow”><img title=”豆瓣” src=”http:images/douban.png” alt=”豆瓣” /></a>
<a title=”百度贴吧” rel=”nofollow” href=”http://tieba.baidu.com/i/app/open_share_api?link=<?php echo $domainurl; ?>&source=<?php echo $sitename; ?>&title=<?php echo $title; ?>&link=%20<?php echo $permalink; ?>&content=utf-8″ target=”_blank”><img title=”百度贴吧” src=”images/tieba.png” alt=”百度贴吧” /></a>
<a title=”人人” rel=”nofollow” href=”http://share.renren.com/share/buttonshare.do?link=<?php echo $permalink; ?>&title=<?php echo $title; ?>” target=”_blank”><img title=”人人” src=”images/renren.png” alt=”人人” /></a>
<a title=”Twitter” rel=”nofollow” href=”http://twitter.com/home?status=<?php echo $title; ?>%20-%20<?php echo $permalink; ?>” target=”_blank”><img title=”Twitter” src=”images/twitter.png” alt=”Twitter” /></a>
<a title=”Facebook” rel=”nofollow” href=”http://www.facebook.com/share.php?u=<?php echo $permalink; ?>&t=<?php echo $title; ?>” target=”_blank”><img title=”Facebook” src=”images/facebook.png” alt=”Facebook” /></a>
</div>

根据你的图片路径在文中修改相应的img的url即可

二.  修改文章(content-single.php或者single.php)文件。把以下代码加到你想放的位置。

<div id=”share”>
           <?php include(TEMPLATEPATH.”/share.php”);?>
      </div>

三. 刷新文章页面看看效果和测试。

PS:如果碰到中文有乱码问题

因为使用的版本字符编码为UTF-8,所以才需要这样转换,如果是GBK或GB2312,应该是不需要转换的。

这里可以在线转换在地址:http://www.tool.la/UTF-8/


随着智能手机的普及,手机上各种即时通讯APP也是层出不穷,如微信、陌陌等,说到用户量最大、日常应用频率最高的还是非微信莫属,这从另一方面反应了手机用户群在不断的增加,这也是潜在的用户群,分享到微信朋友圈也逐渐成为SEOER们新的引流推广方式。

各种分享网页开始添加了这新一渠道的分享方式,可是各大分享网的分享按钮样式都很大众也很土气,在如今扁平化趋势下,分享按钮也应该有着属于自己的独特风格,现在我就教大家怎么实现这一效果。

在前几天的《如何为wordpress添加个性分享功能(非插件,亲测可用)》中的share文件最后一个div结束标签前加入以下代码:

<a class="jiathis_button_weixin" title=”微信” rel=”nofollow”><img title=”分享到微信” src=”images/weixin.png” alt=”微信二维码” /></a>

div结束标签后加入以下代码:

<script type=”text/javascript” src=”http://v3.jiathis.com/code/jia.js?uid=1″ charset=”utf-8″></script>

<script type="text/javascript" src="http://v3.jiathis.com/code/plugin.client.js" charset="utf-8"></script>

这样既可,weixin.png这张图你可以根据自己的喜好来选择和制作。




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值