Make WordPress Core

Opened 12 years ago

Closed 9 years ago

#23501 closed enhancement (wontfix)

add filter for post count query in WP_Posts_List_Table

Reported by: cardy_web's profile cardy_Web Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.5
Component: Posts, Post Types Keywords:
Focuses: administration Cc:

Description

I've a custom post type "products" with a custom taxonomy "manufacturers"
I've hooked the parse_query filter when fired from edit.php because I've wanted to show posts based on current user criteria (user can edit only products belong to specific manufacturers).
Everything worked as expected, except for the post count in the table header that shows total amount of posts (not a filtered count).
Digging into the code I've found that inside WP_Posts_List_Table constructor (http://core.trac.wordpress.org/browser/trunk/wp-admin/includes/class-wp-posts-list-table.php#L59)the following code is performed:

$this->user_posts_count = $wpdb->get_var( $wpdb->prepare( "
				SELECT COUNT( 1 ) FROM $wpdb->posts
				WHERE post_type = %s AND post_status NOT IN ( 'trash', 'auto-draft' )
				AND post_author = %d
			", $post_type, get_current_user_id() ) );

I think that the simplest solution is to add a filter for the count query. By this way is possibile to customize the query that reflects the effective post count.

Change History (3)

#1 @SergeyBiryukov
12 years ago

  • Version changed from trunk to 3.5

#2 @jeremyfelt
11 years ago

  • Component changed from Administration to Posts, Post Types
  • Focuses admin added

#3 @DrewAPicture
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

There has been no interest or meaningful activity in three years. Closing as wontfix.

Note: See TracTickets for help on using tickets.