1
なぜhttp://localhost/wp/?paged=2とそれ以前のものがwp_queryで動作しないのですか?wpクエリでページ2が動作しない理由
私は15以上の投稿を「カスタム投稿タイプ」からの映画とシリーズを持っています。 フロントエンドの2ページに分かれていますが、古いポストを押すと、そのページはまだ最初のページです。ここで
私のindex.phpループコードです:
<?php
$paged = (get_query_var('page')) ? get_query_var('page') : 1;
$query_args = array(
'post_type' => array('post','series','movie'),
'posts_per_page' => 10,
'paged' => $paged
);
$the_query = new WP_Query($query_args);
?>
<?php if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); ?>
<h1><?php the_title();?></h1>
<?php endwhile; ?>
<div class="col-md-12">
<?php if ($the_query->max_num_pages > 1) { // check if the max number of pages is greater than 1 ?>
<nav class="prev-next-posts">
<div class="prev-posts-link">
<?php echo get_next_posts_link('Older Entries', $the_query->max_num_pages); // display older posts link ?>
</div>
<div class="next-posts-link">
<?php echo get_previous_posts_link('Newer Entries'); // display newer posts link ?>
</div>
</nav>
<?php } ?>
</div>
<?php wp_reset_postdata(); ?>
<?php else: ?>
<article>
<h1>Sorry...</h1>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
</article>
<?php endif; ?>
出現停止されていません私の答えは正しい答えではなかった、あなたは正しいものとしてあなたの答えを確認する必要があるかもしれないので、将来どのような訪問者があなたの質問に来る場合、彼は簡単に解決策を得た – hassan