Make WordPress Core

Opened 14 years ago

Closed 11 years ago

#23501 closed enhancement (wontfix)

add filter for post count query in WP_Posts_List_Table

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

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
14 years ago

  • Version trunk → 3.5

#2 @jeremyfelt
13 years ago

  • Component Administration → Posts, Post Types
  • Focuses admin added

#3 @DrewAPicture
11 years ago

  • Milestone Awaiting Review
  • Resolution → wontfix
  • Status new → closed

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

Note: See TracTickets for help on using tickets.