我不符合下面按钮的外观条件,我做错了什么?
<?php
query_posts( array(
\'post_type\' => \'post\',
\'post_per_page\' => 6,
) );
if( have_posts() ){
while( have_posts() ){
the_post();
?>
<div class="project">
<a href="<?php echo get_permalink(); ?>"><div class="project-img" style="background: url(\'<?php echo get_the_post_thumbnail_url(); ?>\')"></div></a>
<span><?php the_title(); ?></span>
<?php the_excerpt(); ?>
<p class="post-date"><?php the_date(\'d/m/Y\'); ?></p>
</div>
<?php
}
} else {
}
?>
<?php if ( $wp_query->max_num_pages > 1 ) : ?>
<script>
var ajaxurl = \'<?php echo site_url() ?>/wp-admin/admin-ajax.php\';
var true_posts = \'<?php echo serialize($wp_query->query_vars); ?>\';
var current_page = <?php echo (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1; ?>;
var max_pages = \'<?php echo $wp_query->max_num_pages; ?>\';
</script>
<div id="true_loadmore">Загрузить ещё</div>
最合适的回答,由SO网友:Jacob Peattie 整理而成
您已设置\'posts_per_page\' => -1,
, 这意味着每页不受限制的帖子,但正在检查$wp_query->max_num_pages > 1
. 如果你每页都有无限的帖子,那么永远不会有超过1页的帖子。