Get parent page/menu id of current post

I believe you want get_queried_object. If you have set your static front page and blog page from wp-admin->Settings->Reading then get_queried_object will give you information about the page you chose rather than about the posts in the Loop.

Be aware that get_queried_object will return very different types of information depending on the kind of page you are on. From the Codex:

On your posts page it should be a WP_Post object

$thispage = get_queried_object();
var_dump($thispage); // WP_Post object

Leave a Comment