WordPress添加固定位置的百度分享按钮

本文介绍如何在WordPress网站中集成分享按钮,通过简单的两步操作即可实现。首先创建一个名为share.php的模板文件,并将提供的HTML代码复制进去;其次在主题页脚模板footer.php中加入调用代码。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

第一步,在你所用主题目录新建一个名称为: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(); ?>  

 

 

 

 

转载于:https://www.cnblogs.com/wangblognet/p/3440724.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值