[wp-trac] [WordPress Trac] #16603: Add hooks to wp_count_posts()

WordPress Trac noreply at wordpress.org
Fri Jul 19 18:03:17 UTC 2013


#16603: Add hooks to wp_count_posts()
----------------------------------------+-----------------------------
 Reporter:  mikeschinkel                |       Owner:
     Type:  enhancement                 |      Status:  new
 Priority:  normal                      |   Milestone:  Future Release
Component:  Query                       |     Version:
 Severity:  normal                      |  Resolution:
 Keywords:  has-patch commit 3.6-early  |
----------------------------------------+-----------------------------
Changes (by creativeinfusion):

 * cc: wptrac@… (added)


Comment:

 Replying to [comment:8 nacin]:
 >Filters should occur outside caching.

 There's a filter on wp_count_comments that has a similar function to this
 ticket and it's applied before the cache is used at all. This does work
 when wanting to modify the query, though a direct filter on the query
 being used would be better as it would avoid replicating the function.

 > If there is truly a desire to alter the query directly, then a pre_*
 filter should be added. I don't think that is particularly necessary.

 I have sites where we only allow some admin users to see their own posts
 (custom post types typically) which needs a post_author to be added to the
 query.

 At present we use the 'views_edit-{post_type}' filter with a custom count
 posts function that replicates wp_count_posts except for the query change
 (I really didn't want to use the 'query' hook). It's far from ideal not
 least because if this is wanted on regular posts the counts in other
 places (e.g. the right_now dashboard widget) are of course off.

--
Ticket URL: <http://core.trac.wordpress.org/ticket/16603#comment:13>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list