What is the difference of output records?

Hello!

Tell me what the difference output?

Here it is:

<?php
 global $wp_query;

 $wp_query = new WP_Query(array(
 'category_name' =--> 'blog', // 
 'posts_per_page' => '5',
 'paged' => get_query_var('paged') ?: 1 // page pagination
));

while(have_posts()) { the_post(); ?>
 the <div><?php the_title(); ?></div>
<?php }

the_posts_pagination(); 

wp_reset_query(); // reset $wp_query
?>


And this:

<?php 
 $query_projects = new WP_Query(array( 
 'category_name' =--> 'blog', 
 'posts_per_page' => 5
));
?>

 <?php while( $query_projects--->have_posts() ): $query_projects->the_post(); ?>
 the <div><?php the_title(); ?></div>
 <?php endwhile; the_posts_pagination(); wp_reset_postdata(); ?>


In both cases, you use WP_Query and selected blog posts. But in the first case the output using: while(have_posts()) { the_post(); and the second
while( $query_projects->have_posts() ): $query_projects->the_post();
while the first option allows you to display pagination via the_posts_pagination(); , and second to none.

What is the difference between the two?
June 5th 19 at 21:54
1 answer
June 5th 19 at 21:56
Where are all the WORDPRESS guru ??? )))

Find more questions by tags WordPress