> ## Content Index
> Fetch the complete content index at: https://yinguobing.com/blog/llms.txt
> Use this file to discover other available public pages before exploring further.

# 给wordpress添加“返回顶部”功能
- URL: https://yinguobing.com/blog/return-to-top-wordpress/
- Published: 2012-11-06T08:38:55.000Z
- Updated: 2022-05-29T07:24:03.000Z
- Description: 一个“返回顶部”按钮能够实现一键返回顶部。
- Author: 尹国冰
- Tags: 生活故事

有些wordpress主题在页面底部是没有任何小工具的，所以导航功能集中在了顶部。在浏览这类页面时如果有一个“返回顶部”按钮能够实现一键返回顶部，无疑会有更佳的浏览体验。

实现起来也较简单，分两步：

第一步，将以下代码插入主题的footer.php文件中，具体位置在文件末端，的前边，并保存。

```
<div id="full" style="width:64px; height:64px; position:fixed; left:50%; top:600px;  
margin-left:515px; z-index:100; text-align:center; cursor:pointer;">  
<a><img src="<span style="color: #993300;">/return_to_top.png</span>" border=0 alt="返回顶部"></a>  
</div>  
<script src="<span style="color: #993300;">/return_to_top.js</span>" type="text/javascript"></script>

```

第二步，将以下压缩包内的两个文件上传到你网站的根目录。

下载 [return\_to\_top](https://yinguobing.com/blog/content/images/2012/11/return%5Fto%5Ftop.zip)

OK，刷新你的页面试试看！

如果你有其它喜欢的图片，只需要替换上传的图片文件即可，不过文件名要记得修改哦！