-1

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).

closed as unclear what you're asking by birgire, TheDeadMedic, Howdy_McGee, kaiser Mar 8 '16 at 2:59

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

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

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 );
the_title();
the_ID;
the_content();
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.