PHP
1<html> 2<body> 3<ul> 4 <?php $args = array( 5 'numberposts' => 5, //表示(取得)する記事の数 6 'post_type' => 'post-type-name' //投稿タイプの指定 7 ); 8 $customPosts = get_posts($args); 9 if($customPosts) : foreach($customPosts as $post) : setup_postdata( $post ); ?> 10 <li> 11 <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a> 12 <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> 13 </li> 14 <?php endforeach; ?> 15 <?php else : //記事が無い場合 ?> 16 <li><p>記事はまだありません。</p></li> 17 <?php endif; 18 wp_reset_postdata(); //クエリのリセット ?> 19</ul> 20</body> 21</html>
こちらのコードがどうも表示されないのです。
test.phpという名前で作り、test.phpをブラウザでみましたが表示されません。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。