wp_count_attachments

Modify returned attachment counts by mime type.

Description

apply_filters( 'wp_count_attachments', (object) $object_counts, (string) $mime_type ); 

Parameters (2)

0. $object_counts (object) => (object) $counts
An object containing the attachment counts by mime type.
1. $mime_type (string)
The mime type pattern used to filter the attachments counted.

Usage

To run the hook, copy the example below.
  1. $object_counts = apply_filters( 'wp_count_attachments', $object_counts, $mime_type ); 
  2.  
  3. if ( !empty( $object_counts ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the wp_count_attachments callback 
  2. function filter_wp_count_attachments( $object_counts, $mime_type ) { 
  3. // make filter magic happen here... 
  4. return $object_counts
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'wp_count_attachments', 'filter_wp_count_attachments', 10, 2 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'wp_count_attachments', 'filter_wp_count_attachments', 10, 2 ); 

Defined (1)

The filter is defined in the following location(s).

/wp-includes/post.php  
  1. return apply_filters( 'wp_count_attachments', (object) $counts, $mime_type );