【发布时间】:2018-03-14 15:27:20
【问题描述】:
我们正在使用 Infinite Scroll 插件加载分页的 Wordpress 页面。这很好用,但是,当没有足够的帖子来使用无限滚动时,我们会留下“加载更多”按钮,这显然不是必需的,也没有任何功能。
我们如何在不需要时隐藏加载更多按钮?我们可以使用 is_paged() 作为条件,还是我在 Infinite Scroll 文档中遗漏了什么?
谢谢
JQUERY
// Init infinite scroll
$grid.infiniteScroll({
path: '.pagination .next a',
append: '.articles .article',
outlayer: iso,
loadOnScroll: false,
scrollThreshold: false,
button: '.load-more-button',
hideNav: '.pagination',
status: '.load-status',
history: false,
debug: true
});
HTML
<div class="grid articles">
<?php while ( have_posts() ) : the_post(); ?>
<div class="article">
Article content here!
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
</div>
<div class="load-more">
<button class="load-more-button">Load More</button>
</div>
<nav class="grid pagination">
<div class="prev"><?php echo get_previous_posts_link('Previous'); ?></div>
<div class="next"><?php echo get_next_posts_link('Next'); ?></div>
</nav>
【问题讨论】: