描述:
显示当前文章ID
参数:
此函数没有参数
用法:
<?php get_the_ID(); ?>
示例:
<?php
$id = get_the_ID();
$dropdown = "<select name='dropdown-".$id."' >";
$dropdown .= "<option id='option1-". $id ."'>Option 1</option>";
$dropdown .= "</select>";
?>
源文件:
/**
* Retrieve the ID of the current item in the WordPress Loop.
*
* @since 2.1.0
*
* @return int|false The ID of the current item in the WordPress Loop. False if $post is not set.
*/
function get_the_ID() {
$post = get_post();
return ! empty( $post ) ? $post->ID : false;
}
发表评论
还没有评论,快来抢沙发吧!