HotNews Pro 2.72集成的固定在頁面左側(cè)的百度分享按鈕,可方便讀者分享自己喜歡的文章,本文教你把這個(gè)固定的分享按鈕添加到其它主題中。
第一步,在你所用主題目錄新建一個(gè)名稱為:share.php的模板文件,將下面的代碼復(fù)制到進(jìn)去并保存:
- <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(newDate()/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>
第二步,將調(diào)用代碼:
- <?php include('share.php'); ?>
添加到主題頁腳模板footer.php這句上面:
- <?php wp_footer(); ?>
以上代碼在WP默認(rèn)主題Twenty Twelve中測試通過,針對(duì)不同主題的頁面寬度,可適當(dāng)調(diào)整固定按鈕的位置,代碼中有注釋。
評(píng)論