[wp-trac] [WordPress Trac] #40042: Empty Author ID on first time action pre_get_post is called.
WordPress Trac
noreply at wordpress.org
Wed Mar 8 01:53:46 UTC 2017
#40042: Empty Author ID on first time action pre_get_post is called.
--------------------------+----------------------
Reporter: BackuPs | Owner:
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: General | Version: 4.7.2
Severity: normal | Resolution: invalid
Keywords: | Focuses:
--------------------------+----------------------
Changes (by dd32):
* status: new => closed
* resolution: => invalid
* milestone: Awaiting Review =>
Comment:
Put simply - the array of fields passed to the `pre_get_posts` call is the
raw arguments as parsed from the URL.
In the case of `/author/dd32` the `author_name = dd32` field will be set,
in the case of `?author=123` `author = 123` will be set.
You should handle both of those cases and find the user_id by calling
`get_user_by( 'user_nicename', $author_name )`
--
Ticket URL: <https://core.trac.wordpress.org/ticket/40042#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list