The $post
global always holds the first post in the main query object before the loop (if nothing breaks it before that). On singular pages and static front pages, it will always be the same as the queried object. For all archives, the home page and the blog page, $post
holds the first post in the $posts
array before the loop and the last post in the $posts
array after the loop.
If you need to target the actual page object on the blog page, you will need to make use of the queried object, and not the $post
global. The queried object will hold the page object of the page which was used as the page set as blog page. As I said before, $post
will hold the first post in the loop.
You also need to remember that the $post
global is extremely unreliable because anything can change it. For more reliability, to access the page object on singular pages (single post pages, true pages and static front pages) or the blog page, use get_queried_object()
. If you looking for even more reliability, you can use $GLOBALS['wp_the_query']->get_queried_object()
. I just recently did an answer on this very subject