• Resolved luciendub

    (@luciendub)


    Hi,
    I wonder if I understand the loop well. I got this code, and I wonder if it is ok if I don’t put a endwhile?

    <?php
    $args = array (
      'post_type'              => 'offresdemploi',
      'posts_per_page'         => '3',
      'order'                  => 'DESC',
    );
    
    $query = new WP_Query( $args );
    
    if ( $query->have_posts() ) { while ( $query->have_posts() ) {
        $query->the_post(); ?>
    
         <li>
          Content...
         </li>
    
     <?php }
    } else {
    
    }
    wp_reset_postdata(); ?>

    Does the wp_reset_postdata do the job by stopping the loop?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Wp Query (is endwhile essential?)’ is closed to new replies.