0

Ok, I am having a very strange issue. Look at the code, it is quite self-explanatory. It throws an infinite loop, and I am not sure why.

<?php
    //Only display 3 posts in the loop
    $args = array(
        'posts_per_page' => '3',
    );

    frontpage_query = new WP_Query( $args );

    if ( $frontpage_query->have_posts() ) : while ( have_posts() ) : $frontpage_query->the_post(); ?>

        <?php get_template_part( 'parts/loop', 'frontpage-grid' ); ?>

    <?php endwhile; endif; ?>

1 Answer 1

3
while (have_posts()) :

should be

while ($frontpage_query->have_posts()) :
Sign up to request clarification or add additional context in comments.

1 Comment

I am not sure, how I missed that. It looks like I should go to sleep. Thank you very much Barmar, I will accept your answer as soon as I can.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.