Answer the question
In order to leave comments, you need to log in
What is the difference in the output methods?
Hello!
What is the difference in output?
Like this:
<?php
global $wp_query;
$wp_query = new WP_Query(array(
'category_name' => 'blog', //
'posts_per_page' => '5',
'paged' => get_query_var('paged') ?: 1 // страница пагинации
));
while(have_posts()) { the_post(); ?>
<div><?php the_title(); ?></div>
<?php }
the_posts_pagination();
wp_reset_query(); // сброс $wp_query
?>
<?php
$query_projects = new WP_Query(array(
'category_name' => 'blog',
'posts_per_page' => 5
));
?>
<?php while( $query_projects->have_posts() ): $query_projects->the_post(); ?>
<div><?php the_title(); ?></div>
<?php endwhile; the_posts_pagination(); wp_reset_postdata(); ?>
while(have_posts()) { the_post();
, and in the secondwhile( $query_projects->have_posts() ): $query_projects->the_post();
, while the first option allows you to display pagination through the_posts_pagination(); , but the second one is not. Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question