给你的WordPress网站添加固定的百度分享按钮

WordPress WordPress固定在页面左侧的百度分享按钮,可方便读者分享自己喜欢的文章,本文教你把这个固定的分享按钮添加到其它主题中。 第一步,在你所用主题目录新建一个名称为:share.php的模板文件,将下面的代码复制到进去并保存: <div id="share"> <div class...
给你的WordPress网站添加固定的百度分享按钮
WordPress

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&amp;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中测试通过,针对不同主题的页面宽度,可适当调整固定按钮的位置,代码中有注释。

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

给TA打赏
共{{data.count}}人
人已打赏
wordpress教程

WordPress友情链接函数(wp_list_bookmarks)详解

2023-2-16 23:48:10

wordpress教程

WordPress首页排除特定分类文章

2023-2-16 23:48:13

!
你也想出现在这里?立即 联系我们吧!
信息
0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
搜索