社会化分享被现在越来越多的网站重视,在自己的文章下面添加一组简单的分享按钮,不但会给用户带来好的体验,而且可以给广大的个人网站站主带来流量。在国内人人网和开心网包括Facebook的兴起就可以很好的说明这点。而且现在社会化分享将成为各大网站流量的主要来源。今天怪僧就为大家介绍一个通过代码简单的为你的网站添加分享的办法。

出来的结果可以看我下面的分享收藏:

1.首先,下载我下面的图片,然后上传到你的空间,我的是上传到根目录下的images文件夹下。

2.在样式表中添加以下代码:

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
.cpicon{
 font-size: 12px;
 height: 64px;
 width: 576px;
 padding: 0 0 0 29px;
 margin: 25px 0px 5px 0px;
 background: url(http://www.chhua.com/images/fenxiang.jpg) no-repeat;}
.cpicon ul {
 list-style:none;
 margin: 0px;
 padding:0px;}
.cpicon li {
 float:left;
 width:24px;
 height: 24px;
 margin: 4px;}
.cpicon a {
 text-indent: -9999px;
 font-size: 2px;
 display: block;
 width:24px;height: 24px;}

3.在文章页面模板 (single.php) 中找到<?php the_content(); ?>在其后面添加:

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<div class="cpicon">
 
         <li><a href="http://myweb.cn.yahoo.com/popadd.html?title=<?php the_title();?>&amp;url=< ?php the_permalink() ?>&amp;tag=&amp;summary=" title="Yahoo书签" target="_blank" rel="nofollow">Yahoo书签</a></li>
        <li><a href="http://www.google.com/bookmarks/mark?op=edit&bkmk=<?php the_permalink() ?>&title=< ?php the_title();?>" title="Google书签" target="_blank" rel="nofollow">Google书签</a></li>
        <li><a href="http://cang.baidu.com/do/add?it=<?php the_title();?>&iu=< ?php the_permalink() ?>&dc=&fr=ien#nw=1″ title="百度搜藏" target="_blank" rel="nofollow">百度搜藏</a></li>
        <li><a href="https://favorites.live.com/quickadd.aspx?marklet=1&mkt=en-us&url=<?php the_permalink() ?>&title=< ?php the_title();?>&top=1″ title="Windows Live" target="_blank" rel="nofollow">Windows Live</a></li>
        <li><a href="http://my.poco.cn/fav/storeIt.php?t=<?php the_title();?>&u=< ?php the_permalink() ?>" title="POCO网摘" target="_blank" rel="nofollow">POCO网摘</a></li>
        <li><a href="http://www.facebook.com/share.php?u=<?php the_permalink() ?>&title=< ?php the_title();?>" title="FaceBook" target="_blank" rel="nofollow">FaceBook</a></li>
        <li><a href="http://www.plaxo.com/?share_link=<?php the_permalink() ?>" title="Plaxo" target="_blank" rel="nofollow">Plaxo</a></li>
        <li><a href="http://www.myspace.com/Modules/PostTo/Pages/?u=<?php the_permalink() ?>&t=< ?php the_title();?>&l=3&c=" title="MySpace" target="_blank" rel="nofollow">MySpace</a></li>
        <li><a href="http://www.xianguo.com/service/submitfav/?link=<?php the_permalink() ?>&title=< ?php the_title();?>" title="鲜果" target="_blank" rel="nofollow">鲜果</a></li>
        <li><a href="http://www.diglog.com/submit.aspx?act=like&returnurl=true&title=<?php the_title();?>&url=< ?php the_permalink() ?>&description=" title="DigLog" target="_blank" rel="nofollow">DigLog</a></li>
        <li><a href="http://www.shouker.com/mc/col/post2.aspx?title=<?php the_title();?>&surl=< ?php the_permalink() ?>" title="收客网" target="_blank" rel="nofollow">收客网</a></li>
        <li><a href="http://digg.com/submit?url=<?php the_permalink() ?>&title=< ?php the_title();?>" title="Digg" target="_blank" rel="nofollow">Digg</a></li>
        <li><a href="http://www.mixx.com/submit?page_url=<?php the_permalink() ?>" title="Mixx" target="_blank" rel="nofollow">Mixx</a></li>
        <li><a href="http://twitter.com/home/?status=<?php the_title();?> < ?php the_permalink() ?> via @fearlessz&source=WhoopNetworkBlog" title="Twitter" target="_blank" rel="nofollow">Twitter</a></li>
        <li><a href="http://www.plurk.com/m?content=<?php the_permalink() ?>&qualifier=shares" title="Plurk" target="_blank" rel="nofollow">Plurk</a></li>
        <li><a href="http://fanfou.com/sharer?u=<?php the_permalink() ?>&t=< ?php the_title();?>" title="饭否" target="_blank" rel="nofollow">饭否</a></li>
        <li><a href="http://t.sina.com.cn/k/<?php the_title();?> < ?php the_permalink() ?>" title="新浪微博" target="_blank" rel="nofollow">新浪微博</a></li>
        <li><a href="http://tongxue.com" title="同学" target="_blank" rel="nofollow">同学 </a></li>
        <li><a href="http://shuqian.qq.com/post?title=<?php the_title();?>&uri=< ?php the_permalink() ?>" title="QQ书签" target="_blank" rel="nofollow">QQ书签</a></li>
        <li><a href="http://del.icio.us/post?url=<?php the_permalink() ?>&title=< ?php the_title();?>" title="Del.icio.us" target="_blank" rel="nofollow">Del.icio.us</a></li>
        <li><a href="http://www.mister-wong.com/index.php?action=addurl&bm_url=<?php the_permalink() ?>&bm_description=< ?php the_title();?>&bm_notice=" title="Mister Wong" target="_blank" rel="nofollow">Mister Wong</a></li>
        <li><a href="http://vivi.sina.com.cn/collect/icollect.php?pid=28&title=<?php the_title();?>&url=< ?php the_permalink() ?>" title="新浪 vivi" target="_blank" rel="nofollow">新浪 vivi</a></li>
        <li><a href="http://www.365key.com/storeit.aspx?t=<?php the_permalink() ?>&h=< ?php the_title();?>" title="365key网摘" target="_blank" rel="nofollow">365key网摘</a></li>
        <li><a href="http://kaixin001.com" title="开心" target="_blank" rel="nofollow">开心</a></li>
        <li><a href="http://share.renren.com/share/buttonshare.do?link=<?php the_permalink() ?>&title=< ?php the_title();?>" title="人人" target="_blank" rel="nofollow">人人</a></li>
        <li><a href="http://www.douban.com/recommend/?url=<?php the_permalink() ?>&title=< ?php the_title();?>&v=1″ title="豆瓣" target="_blank" rel="nofollow">豆瓣</a></li>
        <li><a href="http://9.douban.com/recommend/?url=<?php the_permalink() ?>&title=< ?php the_title();?>" title="9点" target="_blank" rel="nofollow">9点</a></li>
        <li><a href="http://leshou.com/post?act=shou&reuser=&title=<?php the_title();?>&url=< ?php the_permalink() ?>&intro=&tags=&tool=1″ title="乐收网" target="_blank" rel="nofollow">乐收网</a></li>
        <li><a href="http://www.technorati.com/faves?add=<?php the_permalink() ?>" title="Technorati" target="_blank" rel="nofollow">Technorati</a></li>
        <li><a href="http://www.stumbleupon.com/submit?url=<?php the_permalink() ?>&title=< ?php the_title();?>" title="StumbleUpon" target="_blank" rel="nofollow">StumbleUpon</a></li>
        <li><a href="http://www.reddit.com/submit?url=<?php the_permalink() ?>" title="Reddit" target="_blank" rel="nofollow">Reddit</a></li>
        <li><a href="http://www.diguff.com/diguShare/bookMark_FF.jsp?&title=<?php the_title();?>&url=< ?php the_permalink() ?>" title="嘀咕" target="_blank" rel="nofollow">嘀咕</a></li>
        <li><a href="http://zuosa.com/collect/Collect.aspx?u=<?php the_permalink() ?>&t=< ?php the_title();?>&s=bjnahan.net" title="做啥" target="_blank" rel="nofollow">做啥</a></li>
        <li><a href="http://jiwai.de/wo/share/s?u=<?php the_permalink() ?>&t=< ?php the_title();?>" title="叽歪" target="_blank" rel="nofollow">叽歪</a></li>
        <li><a href="http://9911.com" title="9911″ target="_blank" rel="nofollow">9911</a></li>
        <li><a href="http://pnuo.cn/space-share.html" title="朋友" target="_blank">朋友</a></li>
 
 </div>

自由转载,转载请注明: 转载自WEB开发笔记 www.chhua.com

本文链接地址: 为wordpress的每一篇文章添加分享收藏按钮 http://www.chhua.com/web-note440

相关笔记

更多