简体   繁体   中英

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.

<?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; ?>
while (have_posts()) :

应该

while ($frontpage_query->have_posts()) :

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM