万が一、当サイトで重大な問題を発見した際などは、フォーラムや WordSlack #docs チャンネルでお知らせください。</p>
テンプレートタグ/the ID
説明
現在の投稿の ID を表示します。必ずループの中で使用してください。
注: このテンプレートタグは投稿で ID を表示するために使用します。ID を取得したい場合は get_the_ID を使用します。
使い方
<?php the_ID(); ?>
パラメータ
なし
用例
基本的な使用方法
<p>投稿番号: <?php the_ID(); ?></p>
XHTML で 要素の id に投稿番号を使用する場合
投稿にユニークなアンカー ID を付与します:
<h3 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h3>
注: XHTML では要素の ID を数字から始めることはできません。the_ID() は数値を返しますので、上記の「post-<?php the_ID(); ?>」のようにテキスト+記事 ID という形式にする必要があります。
更新履歴
新規導入: 0.71
ソースファイル
the_ID() は wp-includes/post-template.php
にあります。
関連項目
投稿タグ: body_class(), next_image_link(), next_post_link(), next_posts_link(), post_class(), post_password_required(), posts_nav_link(), previous_image_link(), previous_post_link(), previous_posts_link(), single_post_title(), sticky_class(), the_category(), the_category_rss(), the_content(), the_content_rss(), the_excerpt(), the_excerpt_rss(), the_ID(), the_meta(), the_shortlink(), the_tags(), the_title(), the_title_attribute(), the_title_rss(), wp_link_pages(),
最新英語版: WordPress Codex » Function Reference/the_ID (最新版との差分)