demoblog by mmts

2025-02-15
トップページに最新の投稿を表示

have_post()
the_date()
the_title()
the_permalink()
get_the_date()

if else文
<?php if( ここに条件 ): ?>
ここにtrueの処理
<?php else: ?>
ここにfalseの処理
<?php endif;?>

ループ文
<?php while( ここに条件 ) ?>
ここに処理
<?php endwhile; ?>

<?php if(have_posts()): ?>
    <dl>
        <?php while (have_posts()): ?>
             <?php the_post(); ?>
             <dt><?php echo get_the_date(); ?></dt>
             <dd><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></dd>
        <?php endwhile; ?>
    </dl>
<?php else: ?>
    <p>お知らせはありません。</p>
<?php endif; ?>