首先,您必须找到<div class="entry-content"> 在哪里。它位于您的wp-content/themes/[themename] 文件夹中,位于名为 index.php 或 loop.php 的文件中。在 entry-content 的结束 </div> 之后,添加:
<div class="moreposts" style="display:none"
onclick="$('div.moreposts').slideUp();$(document).trigger('retrieve.infscr');">
Show more
</div>
<script>
$(document).ajaxError(function(e,xhr,opt){
if (xhr.status == 404) $('div.moreposts').slideUp("normal", function() { $(this).remove(); } );
});
</script>
现在,在无限滚动配置(Wordpress 管理 -> 设置 -> 无限滚动)中,将其添加到“获取下一篇文章后要调用的 Javascript”框:
$(window).unbind('.infscr');
setTimeout("$('div.moreposts').slideDown();", 1000);
最后为按钮设置样式以使其看起来更漂亮(添加到 style.css):
.moreposts {
display:block;
border-radius:5px; -moz-border-radius:5px; -webkit-border-radius:5px;
border: 1px solid #ddd;
background: #efefef;
text-align: center;
font-weight: bold;
box-shadow: 2px 2px 2px rgba(50,50,50,0.4); color: #444;
text-decoration: none;
padding: 5px;
margin-bottom: 20px;
cursor: pointer;
}
.moreposts:hover {
background: #dfdfdf;
color: #222;
}
请注意,这将自动执行第一个后加载,然后手动执行后续加载。这是脚本自动隐藏之前/下一个按钮所必需的。