Home > Net >  wordpress custom post pagination show same post on all pages
wordpress custom post pagination show same post on all pages

Time:03-18

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 >
                            <h1 ><?php the_title(); ?></h1>
                        </header>
                        <div >
                            <?php the_excerpt(); ?>
                            <a href="<?php the_permalink(); ?>">Read More</a>
                        </div>
                    </article>
            <?php
                endwhile;
                wp_pagenavi(
                    array(
                        'query' => $wp_query,
                    )
                );
            endif;
        ?>

CodePudding user response:

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

        $args = array(
            'post_type' => 'case_studiess',
            'post_status' => 'publish',
            'posts_per_page' => 10,
            'paged'=>$paged
        );
  • Related