Hello!
Maybe this is a simple question, but I found so many different
answers and none worked for me, so I do have to ask it here:
how do I get the ID of the current page in php?
I tried:
$currId = get_the_ID();
but this works only for pages with NO posts (otherwise
it seems to give me an post-id even without the loop
-> could this be true?)
or
wp_title( '|', true, 'right' )
this seems to be empty.
or
global $post;
$post->ID
This returns the ID of a post (if there is at least one).
I also found this one:
$page_object = get_queried_object();
$page_id = get_queried_object_id();
This one always returns 0.
So: which function returns the current page (not the posts) ID
outside the loop?
Thank you for help!