Answer the question
In order to leave comments, you need to log in
How to paginate wordpress posts?
Here are the posts:
<?php
$news = get_posts(['category' => 'news', 'posts_per_page' => 7]);
foreach ($news as $item):
?>
<div class="news-blocks__block">
<div class="news-blocks__block-image">
<a href="<?= $item->guid ?>"><img src="<?= get_the_post_thumbnail_url($item->ID, 'large') ?>" alt="<?= get_field('subtitle', $item->ID) ?>" /></a>
</div>
<h5><a href="<?= $item->guid ?>"><?= get_field('subtitle', $item->ID) ?></a></h5>
<span><i class="ion-calendar"></i><?= get_the_date('', $item->ID) ?></span>
<p><?= get_field('description', $item->ID) ?></p>
</div>
<?php endforeach; ?>
Answer the question
In order to leave comments, you need to log in
Hello!
Custom pagination example -
dimox.name/wordpress-pagination-without-a-plugin Plugin
can be integrated - WP Page Navi
Custom pagination example - https://md7.info/fakty
<?php global $wp_query;
$wp_query = new WP_Query(array(
'posts_per_page' => '12', // кол-во записей на страницу
'post_type' => 'post', // тип записи.
'paged' => get_query_var('paged') ?: 1 // страница пагинации
));
while( have_posts() ) { the_post();
// Здесь ваш код и кастомные поля
// Например,
?>
<h2><?php the_title (); ?></h2>
<?php the_field('custom_field'); ?>
<?php }
// пагинация
if (function_exists('wp_corenavi')) wp_corenavi(); // кастомная пагинация, которую я использую
wp_reset_query(); ?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question