

WordPress固定在页面左侧的百度分享按钮,可方便读者分享自己喜欢的文章,本文教你把这个固定的分享按钮添加到其它主题中。
第一步,在你所用主题目录新建一个名称为:share.php的模板文件,将下面的代码复制到进去并保存:
<div id=\"share\">
<div class=\"share\">
<div id=\"bdshare\" class=\"bdshare_t bds_tools get-codes-bdshare\">
<a class=\"bds_tsina\"></a>
<a class=\"bds_tqq\"></a>
<a class=\"bds_qzone\"></a>
<a class=\"bds_renren\"></a>
<span class=\"bds_more\"></span>
</div>
<div style=\"clear:both;\"></div>
</div>
</div>
<script type=\"text/javascript\" id=\"bdshare_js\" data=\"type=tools&uid=0\" ></script>
<script type=\"text/javascript\" id=\"bdshell_js\"></script>
<script type=\"text/javascript\">
document.getElementById(\"bdshell_js\").src = \"http://bdimg.share.baidu.com/static/js/shell_v2.js?cdnversion=\" + Math.ceil(new Date()/3600000)
</script>
<style type=\"text/css\">
#share {
display:block;
width:35px;
margin-left:-546px;/* 修改左右位置 */
position:fixed;
left:50%;
top:420px;/* 修改上下位置 */
_margin-left:-546px;/* IE6修改左右位置 */
_position:absolute;
_margin-top:420px;/* IE6修改上下位置 */
_top:expression(eval(document.documentElement.scrollTop));
}
.share {
background:#fff;
width:24px;
border: 1px solid #ccc;
border-radius:5px 0 0 5px;
}
#bdshare_l {
border-radius: 5px;
}
div #bdshare_l_c {
border: 1px solid #ccc;
border-radius: 5px;
}
#bdshare h6, #bdshare_s h6,#bdshare p, #bdshare_s p {
display:none;
}
</style>
第二步,将调用代码:
<?php include(\'share.php\'); ?>
添加到主题页脚模板footer.php这句上面:
<?php wp_footer(); ?>
以上代码在WP默认主题Twenty Twelve中测试通过,针对不同主题的页面宽度,可适当调整固定按钮的位置,代码中有注释。
© 版权声明
1. 资源都是经过站长或作者收集测试修改后发布分享。如若转载请在文内以超链形式注明狐狸库文章出处,谢谢合作!
2. 本站除原创内容,其余所有内容均收集自互联网,仅限用于学习和研究目的,本站不对其内容的合法性承担任何责任。如有版权内容,请通知我们或作者删除,其版权均归原作者所有,本站虽力求保存原有版权信息,但因众多资源经多次转载,已无法确定其真实来源,或已将原有信息丢失,所以敬请原作者谅解!
3. 本站用户所发布的一切资源内容不代表本站立场,并不代表本站赞同其观点和对其真实性负责,若您对本站所载资源作品版权归属存有异议,请留言附说明联系邮箱,我们将在第一时间予以处理 ,同时向您表示歉意!为尊重作者版权,请购买原版作品,支持您喜欢的作者,谢谢!
4. 本站一律禁止以任何方式发布或转载任何违法的相关信息,访客如有发现请立即向站长举报;本站资源文件大多存储在云盘,如发现链接或图片失效,请联系作者或站长及时更新。
THE END
请登录后查看评论内容