Identify the page being shown while in The Loop

I believe you want get_queried_object. That will return information about the page per se and not necessarily about the posts/pages being displayed in the Loop.

Be aware that it returns very different information depending on the type of page you are one. It will return user information on an author archive, for example, but category information on a category archive, and sometime it returns NULL.

Related

https://wordpress.stackexchange.com/a/98138/21376

Leave a Comment