Make WordPress Core

Opened 11 years ago

Closed 8 years ago

#22992 closed enhancement (worksforme)

get_the_author() not working outside the post query

Reported by: alexvorn2's profile alexvorn2 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)

#1 @alexvorn2
11 years ago

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.

#2 @SergeyBiryukov
11 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

#3 @nacin
10 years ago

  • Component changed from Template to Users
  • Focuses template added
  • Type changed from defect (bug) to enhancement

#4 @wonderboymusic
8 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.