<?php $populargb = new WP_Query('showposts=5' );
while ( $populargb->have_posts() ) {
$populargb->the_post(); ?>
<li>
<a href="<?php the_permalink(); ?>">
<div class="blog__list__img">
<?php the_post_thumbnail(); ?>
</div>
<div class="blog__list__content">
<h2 class="blog__list__content__h2"><?php the_title() ?></h2>
<p class="blog__list__content__description"><?= get_the_excerpt(); ?></p>
<span class="blog__list__content__date"><?php the_time("j F Y") ?></span>
</div>
</a>
</li>
<?php } ?>
Добрый день. У меня вот такой код. И я пытался сделать пагинацию, но у меня он не выводил ее. Вообще даже цифры страниц. Подскажите как добавить пагинацию ?
Посмотрите примерно вот это
<?php
// set the "paged" parameter (use 'page' if the query is on a static front page)
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
// the query
$the_query = new WP_Query( 'cat=1&paged=' . $paged );
?>
<?php if ( $the_query->have_posts() ) : ?>
<?php
// the loop
while ( $the_query->have_posts() ) : $the_query->the_post();
?>
<?php the_title(); ?>
<?php endwhile; ?>
<?php
// next_posts_link() usage with max_num_pages
next_posts_link( 'Older Entries', $the_query->max_num_pages );
previous_posts_link( 'Newer Entries' );
?>
<?php
// clean up after the query and pagination
wp_reset_postdata();
?>
<?php else: ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
Апостиль в Лос-Анджелесе без лишних нервов и бумажной волокиты
Основные этапы разработки сайта для стоматологической клиники
Продвижение своими сайтами как стратегия роста и независимости