get_available_post_mime_types

Get all available post MIME types for a given post type.

Description

get_available_post_mime_types( (string) $type = 'attachment' ); 

Parameters (1)

0. $type — Optional. (string) => 'attachment'
The type.

Usage

  1. if ( !function_exists( 'get_available_post_mime_types' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/post.php'; 
  3.  
  4. // The type. 
  5. $type = 'attachment'; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = get_available_post_mime_types($type); 
  9.  

Defined (1)

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

/wp-admin/includes/post.php  
  1. function get_available_post_mime_types($type = 'attachment') { 
  2. global $wpdb; 
  3.  
  4. $types = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT post_mime_type FROM $wpdb->posts WHERE post_type = %s", $type)); 
  5. return $types;