[英]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.