Wordpress get_the_ID()只返回get_the_title()返回标题?
问题描述:
我正在努力与wordpress模板。在我的一个主题模板中,我有以下几行Wordpress get_the_ID()只返回get_the_title()返回标题?
<?php
echo get_the_ID(); // displays nothing
echo get_the_title(); // displays "Hello World! this is title"
?>
为什么get_the_ID()不返回任何内容?我想要当前页面的页面ID。
答
这工作循环中:循环
<?php $this_page_id = get_the_ID(); echo $this_page_id ; ?>
外:
<?php $this_page_id = $wp_query->post->ID; echo $this_page_id ;?>
哦,我如何得到一个网页的电流id,如果我在一个循环我不?上面编辑的 – John 2010-03-12 14:26:23
.... – markratledge 2010-03-12 14:48:48