When you share the custom post page, it shows title, description, author of latest post. Even page ID is from latest post.

Does it supposed to work like that? Besides this, it causes many other problems with breadcrumbs, linking to post page (sends you to the latest post instead).

  • How are you sharing? It's unclear to me what you're asking about here, please clarify it, thanks.
    – birgire
    Feb 29, 2016 at 11:12

1 Answer 1


I believe you are talking about the blog page, the page you set as posts page when you select a static front page.

Many functionality like breadcrumbs relies on the $post global. By default, if nothing breaks the $post global, before the loop, the $post global should always hold the first post in the main query loop. Asx we loop through the posts in the loop, $post will be set to the current post in the loop and will eventually holds the last post in the loop after the loop. Remember, any custom query which uses the_post() or setup_postdata( $post ) sets the $post global accordingly, that is why wp_reset_postdata() is so important.

Anyways, on the blog page, the page object is not stored in the $post global, as obviously the page object is not part of the posts in the loop. This is normal default behavior for the posts page/blog page. The page objects are available in the $post global (if nothing breaks the page or $post global) on static front pages, and all singular post pages as the page object is only post in the array of posts in the loop.

The original page object of the page used to set the posts page will be available in the queried object, that is if nothing like query_posts breaks the main query object. So you can get the page object as follow:

$post = get_queried_object();
setup_postdata( $post );
wp_reset_postdata(); // VERY VERY IMPORTANT!!!

Alternatively, if you need to be more reliable, to get the queried object, you can use $GLOBALS['wp_the_query']->get_queried_object() as I have explained here

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