Please tell me this - it is necessary on the main page of the blog where all posts from all categories are displayed to display 5 posts per page and that there is a pagination. On the page with categories, I brought it out in the standard way the_post_pagination , but on the main page where all the categories it for some reason does not display navigation .. Here is a small piece of code with how I tried to display posts and process pagination.
<div class="blog__inner"> <?php get_sidebar(); ?> <div class="blog__content"> <?php $posts = get_posts( array( 'numberposts' => 5, 'category' => 0, 'orderby' => 'date', 'order' => 'DESC', 'include' => array(), 'exclude' => array(), 'meta_key' => '', 'meta_value' =>'', 'post_type' => 'post', 'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса ) ); foreach( $posts as $post ){ setup_postdata($post); ?> <article class="blog__post"> <div class="blog__minicard"> <h2 class="blog__minicard_title"> <a href="<?php the_permalink(); ?>"> <?php the_title(); ?></a> </h2> <div class="post-meta"> <time class="post__date" datetime="<?php the_time('F j, Y'); ?>"> <?php the_time('F j, Y'); ?></time> </div> <div class="blog__minicard_content"> <div class="blog__minicard_images"> <a href="<?php the_permalink(); ?>"> <?php the_post_thumbnail('post-thumb'); ?></a> </div> <?php the_excerpt(); ?> </div> </div> <div class="blog__tab_line"></div> </article> <?php }?> <?php the_posts_pagination(); ?> <?php wp_reset_postdata(); // сброс ?> </div> If only I could do this without plugging in. (I tried, but then the problem begins on the page with categories). If anyone knows how, tell me. Thanks in advance.
This is how it turned out to display pagination, but when you select a page, the transition is made (at least in the address bar), but the posts remain the same, that is, the page does not change and the page is also active in pagination. What is the problem?
<?php query_posts( $args ); while ( have_posts() ) { the_post(); ?> <article class="blog__post"> <div class="blog__minicard"> <h2 class="blog__minicard_title"> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </h2> <div class="post-meta"> <time class="post__date" datetime="<?php the_time('F j, Y'); ?>"><?php the_time('F j, Y'); ?></time> </div> <div class="blog__minicard_content"> <div class="blog__minicard_images"> <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('post-thumb'); ?></a> </div> <?php the_excerpt(); ?> </div> </div> <div class="blog__tab_line"></div> </article> <?php } ?> <?php the_posts_pagination(); ?> <?php // пагинация // вернем global $wp_query wp_reset_query(); ?>