Function Reference/the ID

来自WordPress中文文档
跳转至: 导航搜索

wordpress.org.cn

Description

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().

Usage

%%% <?php the_ID(); ?> %%%

Parameters

This tag has no parameters.

Examples

Default Usage

<p>Post Number: <?php the_ID(); ?></p>

Post Anchor Identifier

Provides a unique anchor identifier to each post:

<h3 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h3>

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.

Change Log

Since: 0.71

Source File

the_ID() is located in onlyincludecodewp-includes/post-template.php/code/onlyinclude

div class=template-description style=padding: 0 1.5em; border: 1px solid #eeeeee; background-color: #f9f9f9

Template Description

Link to the source code on http://core.trac.wordpress.org/browser/.

Parameters

  1. filename
  2. (option) path to codetag/code (version) or codetrunk/code. This option is only used for a new function.br /Default: codetrunk/code -- trunk is the latest bleeding edge development version of WordPress.

Usage

Link to the stable version: pre检查到模板循环:模板:Trac/pre

Link to trunk: pre检查到模板循环:模板:Trac/pre

/div

wordpress.org.cn.

Related

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

includeonlydiv style=clear:both; background-color:#F7F7F7; border:1px solid #CCCCCC; color:#000000; padding:7px; margin:0.5em auto 0.5em auto; vertical-align:middle;See also index of Function Reference and index of Template Tags./div/includeonlynoinclude

Description

This Template is used by Codex:Template Messages.

Usage

pre 检查到模板循环:模板:Message /pre

Result

检查到模板循环:模板:Message

/noinclude