2020年1月23日

「get_posts」で特定のカテゴリを一覧表示させる方法が一番簡単
忘れない様に
<?php$posts = get_posts(array('posts_per_page' => 5, // 表示件数'category' => 'apple' // カテゴリIDもしくはスラッグ名));?><?php if($posts): foreach($posts as $post): setup_postdata($post); ?><!--表示する内容--><a href="<?php the_permalink() ?>"><?php the_title(); ?></a><?php the_time('Y/m/d') ?><?php the_excerpt(); ?></p><p><a href="<?php the_permalink() ?>">続きを見る</a></p><!--表示する内容ここまで--><?php endforeach; endif; ?>the_excerpt()は現在の投稿の抜粋を、文末に 「…」(角括弧+三点リーダー)をつけて表示する
のんびり日々を過ごしながら様々なことにチャレンジしております。基本Apple好きです。