###前提・実現したいこと
Wordpressでthe_posts_paginationを使ってページネーションを実装したいです。
現状、全70件ほどの記事が全表示されているので、それを20件ずつにしたいです。
ずっとうまくいかず悩んでいるのでどなたか助けていただきたいです。。
###発生している問題・エラーメッセージ
the_posts_paginationは『基礎からのWordPress 改訂版』の記述の通り書いたんですが、表示すらされません、、、。
###該当のソースコード
<?php get_header(); ?> <?php if (have_posts()) : ?> <?php $allsearch =& new WP_Query("searchText=$s&showposts=-1"); $key = wp_specialchars($s, 1); $count = $allsearch->post_count; echo '<div class="flex-container"><h2 id="archiveSubTitle">「'.$key.'」に関する記事一覧:'.$count.'件</h2></div>'; ?> <div class="flex-container item-start"> <!-- ******************************************************************************************* * centerArea ******************************************************************************************* --> <section class="col-sm-12 sp-lg-8" id="centerAreaSection"> <ul> <?php while (have_posts()) : the_post(); ?> <li class="flex-fluid justify-start item-start thirdPostArea"> <a href="<?php the_permalink(); ?>"> <figure class="thirdPostIconArea"> <?php $img = get_field('postIcon'); $imgurl = wp_get_attachment_image_src($img, 'full'); ?> <img src="<?php echo $imgurl[0]; ?>" class="thirdPostIcon"> </figure> </a> <div class="thirdPostItem"> <a href="<?php the_permalink(); ?>"> <h3 class="thirdPostTitle"> <?php the_title(); ?> </h3> </a> <a href="<?php the_permalink(); ?>"> <div class="thirdPostSummary"> <div id="nospace"><?php echo get_the_content(); ?></div> </div> </a> </div> </li> <?php endwhile; endif; ?> </ul> <?php $args = array( 'prev_text' => '« NEXT', 'next_text' => 'PREV »', 'show_all' => false, 'mid_size' => 1, 'screen_reader_text' => 'ページナビゲーション', ); the_posts_pagination($args); ?> </section> <!-- ******************************************************************************************* * rightSidebar ******************************************************************************************* --> <section class="col-sm-12 sp-lg-4" id="rightSidebarSection"> <?php get_template_part("./template/mainSidebar"); ?> </section> </div> <?php get_footer(); ?>
###試したこと
管理画面でフロントページの表示を固定ページに、1ページに表示する最大投稿数は20にしています。記事は全部で70件ほどあります。フロントページはindex.phpです。~.jp/page/2とurlを変更しても1ページ目と同じ表示になります。
###補足情報(言語/FW/ツール等のバージョンなど)
WordPressのバージョンは4.8.3です。
回答1件
あなたの回答
tips
プレビュー