新着記事とカテゴリ別の記事一覧が重複しないようにしたい
-
トップページに「カテゴリABC〜の新着記事」と「カテゴリAの一覧」 「カテゴリBの一覧」 「カテゴリCの一覧」 を表示させた時に、 「カテゴリABC〜の新着」 と 「カテゴリAの一覧」 「カテゴリBの一覧」 「カテゴリCの一覧」 で同じ記事が表示されないようにしたいのですが良い方法はありませんでしょうか。
新着記事が8件だった場合、8件が過ぎたものから各カテゴリの一覧に振り分けられていくイメージです。
<div class="sab-t">カテゴリ新着ABC</div> <?php $posts = get_posts('numberposts=8&cat=32,33,34'); global $post;?> <?php foreach($posts as $post): ?> <div class="fps1"> <div class="fps2"><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php echo the_post_thumbnail(); ?></a></div> <div class="ttl01"><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php $title= mb_substr($post->post_title,0,21); echo $title;?>...</a></div> </div> <?php endforeach; ?> <br clear="all"><br /> <div class="sab-t">カテゴリA</div> <?php $posts = get_posts('numberposts=4&cat=32'); global $post;?> <?php foreach($posts as $post): ?> <div class="fps1"> <div class="fps2"><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php echo the_post_thumbnail(); ?></a></div> <div class="ttl01"><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php $title= mb_substr($post->post_title,0,21); echo $title;?>...</a></div> </div> <?php endforeach; ?> <br clear="all"><br /> <div class="sab-t">カテゴリB</div> <?php $posts = get_posts('numberposts=4&cat=33'); global $post;?> <?php foreach($posts as $post): ?> <div class="fps1"> <div class="fps2"><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php echo the_post_thumbnail(); ?></a></div> <div class="ttl01"><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php $title= mb_substr($post->post_title,0,21); echo $title;?>...</a></div> </div> <?php endforeach; ?> <br clear="all"><br /> <div class="sab-t">カテゴリC</div> <?php $posts = get_posts('numberposts=4&cat=34'); global $post;?> <?php foreach($posts as $post): ?> <div class="fps1"> <div class="fps2"><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php echo the_post_thumbnail(); ?></a></div> <div class="ttl01"><a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php $title= mb_substr($post->post_title,0,21); echo $title;?>...</a></div> </div> <?php endforeach; ?> <br clear="all"><br />
上記では重複、offsetでは表示されない記事が出てしまう問題を解決したいです。
6件の返信を表示中 - 1 - 6件目 (全6件中)
6件の返信を表示中 - 1 - 6件目 (全6件中)
- トピック「新着記事とカテゴリ別の記事一覧が重複しないようにしたい」には新たに返信することはできません。