Skip to content
Advertisement

wordpress custom post pagination show same post on all pages

Here is my code. Plesae helps me to fix this issue. Actually, I used a page template on WordPress. I try the many articles but do not get exactly what I want

<?php
            $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
            $args = array(
                'post_type' => 'case_studiess',
                'post_status' => 'publish',
                'posts_per_page' => 10
            );
            
            $wp_query = new WP_Query( $args );
        
            if ($wp_query->have_posts()) :
        
                while ($wp_query->have_posts()) :
                    $wp_query->the_post();
            ?>
                    <article data-aos="fade-down" id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                        <?php
                        if (has_post_thumbnail()) :
                            the_post_thumbnail();
                        endif;
                        ?>
                        <header class="entry-header">
                            <h1 class="entry-title"><?php the_title(); ?></h1>
                        </header>
                        <div class="entry-content">
                            <?php the_excerpt(); ?>
                            <a href="<?php the_permalink(); ?>">Read More</a>
                        </div>
                    </article>
            <?php
                endwhile;
                wp_pagenavi(
                    array(
                        'query' => $wp_query,
                    )
                );
            endif;
        ?>

Advertisement

Answer

Please use this query (I’ve added ‘paged’=>$paged)

        $args = array(
            'post_type' => 'case_studiess',
            'post_status' => 'publish',
            'posts_per_page' => 10,
            'paged'=>$paged
        );
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement