How to get current page id
-
for some reasons i still don’t know why global $wp_query; is returning empty arrays. the index keys are showing but the values are all empty.
I tried doing
~~~
global $wp_query;
print_r($wp_query);
~~~
and i got empty values.I have tested
~~~
// Get Current Page ID outside Loop
global $wp_query;
$post_obj = $wp_query->get_queried_object();
$Page_ID = $post_obj->ID;
echo $Page_ID;
~~~yet is not working, what am i doing wrong? as i want to use it in my custom plugin
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘How to get current page id’ is closed to new replies.