pre_get_available_post_mime_types
Filter HookDescription
Filters the list of available post MIME types for the given post type.Hook Information
| File Location |
wp-includes/post.php
View on GitHub
|
| Hook Type | Filter |
| Line Number | 8323 |
Hook Parameters
| Type | Name | Description |
|---|---|---|
string[]|null
|
$mime_types
|
An array of MIME types. Default null. |
string
|
$type
|
The post type name. Usually 'attachment' but can be any post type. |
Usage Examples
Basic Usage
<?php
// Hook into pre_get_available_post_mime_types
add_filter('pre_get_available_post_mime_types', 'my_custom_filter', 10, 2);
function my_custom_filter($mime_types, $type) {
// Your custom filtering logic here
return $mime_types;
}
Source Code Context
wp-includes/post.php:8323
- How this hook is used in WordPress core
<?php
8318 * @since 6.4.0
8319 *
8320 * @param string[]|null $mime_types An array of MIME types. Default null.
8321 * @param string $type The post type name. Usually 'attachment' but can be any post type.
8322 */
8323 $mime_types = apply_filters( 'pre_get_available_post_mime_types', null, $type );
8324
8325 if ( ! is_array( $mime_types ) ) {
8326 $mime_types = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT post_mime_type FROM $wpdb->posts WHERE post_type = %s AND post_mime_type != ''", $type ) );
8327 }
8328
PHP Documentation
<?php
/**
* Filters the list of available post MIME types for the given post type.
*
* @since 6.4.0
*
* @param string[]|null $mime_types An array of MIME types. Default null.
* @param string $type The post type name. Usually 'attachment' but can be any post type.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/post.php
Related Hooks
Related hooks will be displayed here in future updates.