繁体   English   中英

wordpress 自定义帖子分页在所有页面上显示相同的帖子

[英]wordpress custom post pagination show same post on all pages

这是我的代码。 Plesae 帮我解决了这个问题。 其实我用了WordPress上的一个页面模板,试了很多文章都没有得到我想要的

<?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;
        ?>

请使用此查询(我添加了'paged'=>$paged)

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM