WordPress:Template Tags/the ID
來自站長百科
描述[ ]
顯示當(dāng)前文章的ID數(shù)字。必須在The Loop內(nèi)使用這個(gè)標(biāo)簽。
用法[ ]
%%% <?php the_ID(); ?> %%%
例子[ ]
默認(rèn)用法[ ]
<p>Post Number: <?php the_ID(); ?></p>
文章 Anchor標(biāo)示符[ ]
為每篇文章提供一個(gè)獨(dú)一的anchor 標(biāo)示符: <h3 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h3>
注意:在XHTML中,id
屬性不能以一個(gè)阿拉伯?dāng)?shù)字開始。因?yàn)?code>the_ID返回文章ID作為數(shù)字?jǐn)?shù)據(jù),你至少要在ID中包含一個(gè)字母字符,才能將這個(gè)ID用在id
屬性,就如上述的例子那樣。
參數(shù)[ ]
這個(gè)標(biāo)簽沒有參數(shù)。
相關(guān)的[ ]
the_ID, the_title, the_title_attribute, single_post_title, the_title_rss, the_content, the_content_rss, the_excerpt, the_excerpt_rss, previous_post_link, next_post_link, posts_nav_link, the_meta,