Opened 5 months ago

Last modified 5 months ago

#22992 new defect (bug)

get_the_author() not working outside the post query

Reported by: alexvorn2 Owned by:
Priority: normal Milestone: Awaiting Review
Component: Template Version: 3.5
Severity: normal Keywords: close
Cc:

Description

get_the_author() function return empty value if is used outside the :
have_posts() ( the_post() .. function...
the function should return the author name on the author page even if the function is not called inside the query...


Change History (2)

I figured out that this function does work only in the loop by the doc...
I think it should work outside the loop, getting the value from get_queried_object() function... for example use get_queried_object()->display_name if is called outside the loop.

  • Keywords close added

I guess it's a common concept that most of the_*() and get_the_*() functions only work inside the loop.

get_the_author_meta() can be used outside of the loop with an arbitrary user ID:
http://codex.wordpress.org/Function_Reference/get_the_author_meta

Note: See TracTickets for help on using tickets.