media_library_months_with_files

Allows overriding the list of months displayed in the media library.

Description

apply_filters( 'media_library_months_with_files', (null) $null ); 

By default (if this filter does not return an array), a query will be run to determine the months that have media items. This query can be expensive for large media libraries, so it may be desirable for sites to override this behavior.

Parameters (1)

0. $null (null) => null
An array of objects with month and year properties, or null (or any other non-array value) for default behavior.

Usage

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

Defined (1)

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

/wp-includes/media.php  
  1. $months = apply_filters( 'media_library_months_with_files', null );