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 usewp_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") ?>
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.