Answer the question
In order to leave comments, you need to log in
Pagination on WP not working, how to solve the problem?
connected the standard pagination function still does not work, did it through plugins and found functions on the internet, nothing helps, help solve the problem.
<?php
/*
Template Name: index
*/
?>
<?php get_header( ); ?>
<main>
<div class="container">
<div class="bg">
<?php get_template_part( 'template-parts/breadcrumbs') ?>
<div class="material">
<p>В категирии материалов: 1233456</p>
<p>Показанно материалов: 1-10</p>
</div>
<p class="sort">
Сортировать по:
<a href="#">дате ·</a>
<a href="#">названию ·</a>
<a href="#">Рейтингу ·</a>
<a href="#">загрузкам ·</a>
<a href="#">просмотрам</a>
</p>
<h3 class="free_intro">
<?=get_theme_mod('text_index_page')?>
</h3>
<section class="flex-container">
<?php
// параметры по умолчанию
$args = array(
'numberposts' => 6,
'category' => '2,5',
'orderby' => 'date',
'order' => 'DESC',
'post_type' => 'post',
'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса
);
$posts = get_posts( $args );
foreach($posts as $post){ setup_postdata($post);
get_template_part('/template-parts/video_posts' , get_post_format() );
}
wp_reset_postdata(); // сброс
?>
</section>
</div>
</div>
</main>
<?php get_footer( ); ?>
Answer the question
In order to leave comments, you need to log in
This is a standard issue that is easy to google: "wp get_posts pagination". Learn to search for information.
In short, you need to add 'paged' to the request:
$paged = (get_query_var("paged")) ? get_query_var("paged") : 1;
$posts = get_posts( array('paged' => $paged) );
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question