現在のポストの数値IDを表示します。 このタグはLoopの中なければなりません。
注意:この関数は、記事IDを表示し、get_the_ID()を使うIDを返します。
Displays the numeric ID of the current post. This tag must be within The Loop.
Note: This function displays the ID of the post, to return the ID use get_the_ID().
the_IDのテンプレートタグ使用方法
<?php the_ID(); ?>
the_IDのパラメーター
このタグには、パラメーターが全くありません。
This tag has no parameters.
例
デフォルトの使い方
<p>Post Number: <?php the_ID(); ?></p>
記事アンカー識別子
各投稿のユニークなアンカー識別子を提供します:
Provides a unique anchor identifier to each post:
<h3 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h3>
注:XHTMLでは、id属性は数字で開始しないでください。 the_IDは、数値データとして投稿IDを返すので、上記の例ではid属性を使用する前に少なくとも 1つのアルファベット文字列を含める必要があります。
Note: In XHTML, the id attribute must not start with a digit. Since the_ID returns the post ID as numerical data, you should include at least one alphabetical character before using it in an id attribute, as in the example above.
変更ログ
Since: 0.71
ソースファイル
the_ID()は、wp-includes/post-template.php内に位置しています。
the_ID() is located in wp-includes/post-template.php.
関連テンプレートタグ
the_ID, the_title, the_title_attribute, single_post_title, the_title_rss, the_content, the_content_rss, the_excerpt, the_excerpt_rss, wp_link_pages, next_post_link, next_posts_link, previous_post_link, previous_posts_link, posts_nav_link, sticky_class, the_meta