php - Wordpress pagination shows only same posts
one text
My pagination kinda works...I can navigate through the links, but the pages show the same posts. For example, page 5 show the same posts as in page 1 and 2. And another weird behavior is I can't navigate to the page 1, there's not a link on this number. And the pagination sequence is also weird, it's "1, 2, ..., 5, next".
I tried to use wp_reset_postdata();
but didn't work for me.
<?php get_header() ?>
<header class="cc-page-header" id="inicio">
<?php include ("components/Nav.php") ?>
</header>
<section class="ci-page-header bg-blog position-relative">
<div class="vertical-socials">
<a href=""> <img src="<?php echo $home_url?>/assets/images/wpp-icon.png" alt=""></a>
<a href=""> <img src="<?php echo $home_url?>/assets/images/linkedin.png" alt=""></a>
<a href=""> <img src="<?php echo $home_url?>/assets/images/instagram.png" alt=""></a>
<a href=""> <img src="<?php echo $home_url?>/assets/images/youtube.png" alt=""></a>
<a href=""> <img src="<?php echo $home_url?>/assets/images/facebook.png" alt=""></a>
<a href=""> <img src="<?php echo $home_url?>/assets/images/twitter.png" alt=""></a>
</div>
<div class="container-xxl">
<h1 class="text-uppercase ">Blog</h1>
</div>
</section>
<section class="highlight-post-sec">
<div class="container-xxl">
<?php query_posts( array(
'category_name' => 'destaque',
'posts_per_page' => 1,
)); ?>
<?php if( have_posts() ): while ( have_posts() ) : the_post(); ?>
<div class="highlight-wrapper">
<h2 class="highlight-title"> <?php the_title(); ?></h2>
<div class="info-post">
<span class="txt">Postado em: <b> <?php echo get_the_date(); ?></b> </span>
<div class="category">
<?php
foreach((get_the_category()) as $category){
echo $category->name."<br>";
echo category_description($category);
}
?>
</div>
</div>
<div class="img-wrapper">
<?php the_post_thumbnail(); ?>
</div>
<div class="excerpt-wrapper">
<?php the_excerpt(); ?>
<a href="<?php the_permalink()?>" class="keep-reading">Continue Lendo...</a>
</div>
</div>
<div class="share-wrapper">
<div class="col">
<span class="title">Compartilhar</span>
</div>
<div class="col socials-share">
</div>
<div class="col comentaries">
<span> Coment??rios:
<span>
<?php
$comments_count = wp_count_comments($postid);
echo "" . $comments_count->approved ;
?>
</span> </span>
</div>
</div>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
</div>
</section>
<section class="posts-wrapper-sec">
<div class="container-xxl wrapper-posts">
<?php query_posts('posts_per_page=4'); ?>
<?php if(have_posts() ): while (have_posts() ): the_post(); ?>
<a href="<?php the_permalink(); ?>" class="post-wrapper">
<div class="header">
<?php the_post_thumbnail(); ?>
</div>
<div class="infos">
<span class="title">
<?php
echo wp_trim_words( get_the_title(), 10 );
?></span>
<div class="date">
<span class="grey">Postado em <span class="date">
<?php echo get_the_date(); ?>
</span></span>
<span class="category"> <?php
foreach((get_the_category()) as $category){
echo $category->name."<br>";
echo category_description($category);
}
?></span>
</div>
<div class="body">
<p>
<?php
the_excerpt()
?>
</p>
</div>
</div>
</a>
<?php endwhile; else: endif; ?>
</div>
</section>
<section>
<div class="container-xxl">
<div class="pagination-links d-flex justify-content-center align-items-center">
<?php the_posts_pagination( );?>
</div>
</div>
</section>
<?php include ("components/Footerv2.php") ?>
Source