0

I do not fulfill the condition for the appearance of the button below, what do I do wrong?

<?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>
2
  • start by not using query_posts Commented Sep 5, 2017 at 10:46
  • how wright new WP_Query to right?
    – Webear
    Commented Sep 5, 2017 at 13:12

1 Answer 1

0

You've set 'posts_per_page' => -1,, which means unlimited posts per page, but are checking $wp_query->max_num_pages > 1. There's never going to be more than 1 page if you have unlimited posts per page.

2
  • sorry my bad if i use 6 or another number this not working too. I'm edited post.
    – Webear
    Commented Sep 5, 2017 at 9:47
  • Should be posts_per_page, plural post. Didn't catch when I copied your code. Commented Sep 5, 2017 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.