Basically, after setting up the initial "page for post" on the Reading Options, and then add that page to the menu I get the posts when I click on that menu item as expected.

On there I know the post ID (which is the actual page created before setting it as the page for posts) and all the information regarding that same page.

Trouble is, when I click on a specific post, not only the menu item looses its active status, but I can't get hold of that parent page ID.

Is there a way to get that parent page ID, when on a post !?

Edit: For reference, I managed to get it with get_option('page_for_posts'); but that's very ugly. Is not possible that the post associates with it's parent page index ?

2 Answers 2


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

How about global $post before the loop?

  • Even with that. $post->parent comes empty. I managed to manually get it with get_option('page_for_posts'); but that's not elegant at all
    – eduardev
    Mar 29, 2012 at 7:39
  • You're only setting that page as the posts page right? But that page not necessarily is a child of some other page. I think you need to use the ID of the global $post variable, and before the_loop begins. Mar 29, 2012 at 7:47
  • Yes i've set it as the post page indeed. Should that page not be parent of any posts assigned to it ? What do you mean, use the ID of the global $post variable ? I tried it, and parent is empty.
    – eduardev
    Mar 29, 2012 at 7:54
  • Why do you need the parent? You just that post page's info right ? That page doesn't become the posts parent! Mar 29, 2012 at 8:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.