Opened 13 years ago
Closed 10 years ago
#22992 closed enhancement (worksforme)
get_the_author() not working outside the post query
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 3.5 |
| Component: | Users | Keywords: | close |
| Focuses: | template | 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 (4)
#2
@
13 years ago
- 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.
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.