Quantcast
Viewing all articles
Browse latest Browse all 134420

luciendub on "Wp Query (is endwhile essential?)"

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 all articles
Browse latest Browse all 134420

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>