WordPress获取当前Post ID函数:get_the_ID
WordPress函数get_the_ID一般用在主循环The Loop中,以获取当前Post ID。也可以在文章模板、页面模板中使用,在这些页面即使主循环之外也能获取到当前页面的ID。
get_the_ID()
函数使用示例
<?php $id = get_the_ID(); $dropdown = "<select name='dropdown-".$id."' >"; $dropdown .= "<option id='option-" . $id ."'>Option</option>"; $dropdown .= "</select>"; ?>
扩展阅读
get_the_ID()函数位于:wp-includes/post-template.php
相关函数:
- get_post()
- wp_get_archives()
- get_post_comments_feed_link()
- the_ID()
本网站文章仅供交流学习 ,不作为商用, 版权归属原作者,部分文章推送时未能及时与原作者取得联系,若来源标注错误或侵犯到您的权益烦请告知,我们将立即删除.