• Source
    1. <?php
    2. $args = array(
    3. 'post_type' => 'Products', // 投稿タイプのスラッグを指定
    4. 'post_status' => 'publish', // 公開済の投稿を指定
    5. 'posts_per_page' => 5 // 投稿件数の指定
    6. );
    7. $the_query = new WP_Query($args); if($the_query->have_posts()):
    8. ?>
    9. <?php while ($the_query->have_posts()): $the_query->the_post(); ?>
    10.  
    11. <?php echo get_the_date(‘Y年n月d日’); ?><!– 日付 xxxx年xx月xx日表示 –>
    12. <?php the_permalink(); ?><!– 記事リンク –>
    13. <?php echo get_the_title(); ?><!– 記事タイトル –>
    14. <?php the_content(); ?><!– 記事本文 –>
    15.  
    16. <?php endwhile; ?>
    17. <?php wp_reset_postdata(); ?>
    18. <?php else: ?>
    19. <!-- 投稿が無い場合の処理 -->
    20. <?php endif; ?>