Exciting News! Flipper Code is now WePlugins! Same commitment to excellence, brand new identity.

How to use post_mime_types filter in WordPress

Sandeep Kumar Mishra
Sandeep Kumar Mishra
September 23, 2022
5 minutes read

post_mime_types filter

Filters the default list of post mime types.

apply_filters( 'post_mime_types', array $post_mime_types )

Description

This is a filter hook used to filter the default list of post mime types. It’s utilized by the get_post_mime_types() hook to get default post mime types.

Parameters

  • $post_mime_types: (array) Default list of post mime types.

Live Examples

Example 1: Basic Hook Usage

To run the hook, copy the example below.

$post_mime_types = apply_filters( 'post_mime_types', $post_mime_types ); 
                         
if ( !empty( $post_mime_types ) ) { 
    // everything has led up to this point... 
} 

Example 2: Adding a Hook Callback

The following example is for adding a hook callback.

// define the post_mime_types callback 
function weplugins_filter_post_mime_types( $post_mime_types ) { 
    // make filter magic happen here... 
    return $post_mime_types; 
}; 
         
// add the filter 
add_filter( 'post_mime_types', 'weplugins_filter_post_mime_types', 10, 1 ); 

Example 3: Removing a Hook Callback

To remove a hook callback, use the example below.

// remove the filter 
remove_filter( 'post_mime_types', 'weplugins_filter_post_mime_types', 10, 1 ); 

Access Premium WordPress Plugins

Contact Us

If you need any customization, feel free to Contact Us.

Sandeep Kumar Mishra

Sandeep Kumar Mishra

Sandeep Kumar Mishra writes about WordPress and Artificial Intelligence, offering tips and guides to help you master your website and stay updated with the latest tech trends.

Explore the latest in WordPress

Trying to stay on top of it all? Get the best tools, resources and inspiration sent to your inbox every Wednesday.