get_coauthors() doesn't work properly outside the loop
-
Using get_coauthors() outside the loop like so get_coauthors($post_id) does not work properly.
Problem:
Inside get_coauthors(), the terms for the given $post_id are retrieved. However, if no terms are found, the global $post object is used to retrieve post_author. This leads to problems with posts that were created before co-authors-plus was enabled and haven’t been updated since.What should happen:
get_coauthors() should never ask the global $post object about the author when a $post_id is passed. Instead, it needs to get the post of the given $post_id from the database and use that to determine the post author.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘get_coauthors() doesn't work properly outside the loop’ is closed to new replies.