現在の記事のIDを表示します。WordPressループの中で使います。
the_ID();なし。
現在の記事のIDを表示します。
下記の例では記事をラップするarticle要素に記事ごとのIDを付与しています。
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" class="article">
<h2 class="article__heading"><?php the_title(); ?></h2>
<div class="article__content"><?php the_content(); ?></div>
</article>
<?php endwhile; ?>
<?php endif; ?>※当サイトでは初期値とデフォルト値の言葉の定義を区別せず、原則統一して初期値を採用しています。