php - WordPress The Loop and WP Query throws an inifinite loop


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.

    //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; ?>



while (have_posts()) :

should be

while ($frontpage_query->have_posts()) :

People are also looking for solutions to the problem: php - Limit user to their profile page


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.