1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
// カテゴリーを指定し、最新記事1件のアイキャッチ画像を表示する(2018-09-22) function get_eyecatch_fromCategory($category_name="",$thumbnail_size="thumbnail"){ $posts = get_posts( array( 'category_name' => $category_name, 'showposts' => '1' )); global $post; if($posts) { foreach($posts as $post){ setup_postdata($post); the_post_thumbnail($thumbnail_size); echo "<br />"; the_title(); }} } |