Home › Forums › Other › Get the ID of the current page (WordPress) › Re: Get the ID of the current page (WordPress)
January 28, 2012 at 7:06 am
#95603
peterrknight
Member
For people with the same issue of grabbing the post ID I wrote a better solution on my website: Access the current page id anywhere
Basically it involves storing the id in a global variable which you can then access anywhere you need. The global is set with a hook to wp_head by accessing the main page query. Read more on my website for the function.
The above use case would then look like this:
global $main_post_id;
wp_list_pages('sort_order=asc&number=4&exlude='.$main_post_id.');
?>