media_library_months_with_files
Allows overriding the list of months displayed in the media library.
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.
Usage
add_filter( 'media_library_months_with_files', 'wp_kama_media_library_months_with_files_filter' ); /** * Function for `media_library_months_with_files` filter-hook. * * @param stdClass[]|null $months An array of objects with `month` and `year` properties, or `null` for default behavior. * * @return stdClass[]|null */ function wp_kama_media_library_months_with_files_filter( $months ){ // filter... return $months; }
- $months(stdClass[]|null)
- An array of objects with month and year properties, or null for default behavior.
Changelog
Since 4.7.4 | Introduced. |
Where the hook is called
media_library_months_with_files
wp-includes/media.php 4868
$months = apply_filters( 'media_library_months_with_files', null );