Answer the question
In order to leave comments, you need to log in
How to inject standard WordPress pagination into WP_Query() loop?
There is a need on the site, on the index.php page to display articles from a certain category in a cycle. That is, there should be two loops on one page: one is standard, and the second is done using WP_Query (). In general, I'm stuck with pagination for the second one. Very weak in php. Perhaps someone has already encountered this problem and has a solution, please share.
<?php
$query = new WP_Query('cat=17');// вывод постов из категории с id=17
if ($query->have_posts()) {
while ($query->have_posts()) { $query->the_post();
?>
<div class="posts">
<?php if ( function_exists( 'add_theme_support' ) )
the_post_thumbnail( array(250,9999), array('class' => 'imgmainpost') ); ?> <h1 class="mainpage"><?php the_title(); ?></h1>
</div>
<?php }
wp_reset_postdata();//сбрасываем переменную $post
}
?>
<div class="pagenavi">
<?php if (function_exists('wp_corenavi')) wp_corenavi(); ?>
</div>
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