[wp-trac] [WordPress Trac] #27998: the_author_posts() returns an inaccurate value with the author has no published posts

WordPress Trac noreply at wordpress.org
Wed Apr 23 22:02:03 UTC 2014


#27998: the_author_posts() returns an inaccurate value with the author has no
published posts
--------------------------+------------------------------
 Reporter:  jbenton       |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Users         |     Version:  3.0
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------
Changes (by nacin):

 * version:  3.8.3 => 3.0


Comment:

 This happens because:
  * on an author page for someone with no posts (which is a proper 200
 page, not a 404), $post is null
  * get_the_author_posts() uses get_post()->post_author directly
  * count_user_posts() uses get_posts_by_author_sql() to build a WHERE
  * get_posts_by_author_sql() doesn't put a condition on post_author if an
 actual author wasn't passed

 We added count_user_posts() in 3.0, replacing the then-direct SQL in
 get_usernumposts().

--
Ticket URL: <https://core.trac.wordpress.org/ticket/27998#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list