前提・実現したいこと
wordpressにて、バックナンバーページで過去から現在のすべてを表示したいのですが、
最新10件しか表示されず、古いものから順に表示されなくなってしまいます。
開始年からのすべてを表示させるにはどのように修正すればよいでしょうか。
発生している問題
バックナンバーの表示が最新10件しか表示されない。
該当のソースコード
<?php get_header(); ?> <?php APP_breadcrumb(); ?> <!-- /#breadcrumb --> <main id="content"> <div class="post-content backnumber-content"> <header class="page-title"> <div class="inner"> <h1>バックナンバー</h1> </div> </header> <?php $years = array(); while(have_posts()) : the_post(); $year = get_the_time('Y'); if(array_search($year, $years) === false) $years[] = $year; endwhile; $years = array_reverse($years); ?> <nav class="category-nav"> <ul> <?php foreach($years as $year) : ?> <li><a href="#section-year<?php echo $year; ?>"><?php echo $year; ?>年度</a></li> <?php endforeach; ?> </ul> </nav> <div class="post-body"> <?php $last_year = ''; while(have_posts()) : the_post(); $thumb_id = get_post_thumbnail_id(); if($thumb_id) $thumb = wp_get_attachment_image_src($thumb_id, 'full'); $year = get_the_date('Y'); ?> <?php if($last_year != '' && $last_year != $year) : ?> </div> </section> <?php endif; ?> <?php if($last_year != $year) : ?> <section id="section-year<?php echo $year; ?>"> <h2><?php echo $year; ?>年度バックナンバー</h2> <div class="articles"> <?php endif; ?> <article> <div class="inner"> <header> <h3><?php the_title(); ?></h3> </header> <div class="article-body"> <?php if($thumb) : ?><div class="image"><img src="<?php echo $thumb[0]; ?>" alt=""></div><?php endif; ?> </div> <a href="<?php echo get_field('backnumber_link'); ?>" target="_blank" class="button"><img src="<?php echo get_stylesheet_directory_uri(); ?>/assets/images/magazine-view.png" alt=""><span>試読</span></a> </div> </article> <?php $last_year = $year; endwhile; ?> </div> </section> </div> </div> </main> <!-- /#content --> <?php get_footer(); ?>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2018/10/16 05:47
2018/10/16 05:58 編集
退会済みユーザー
2018/10/16 06:36