get_available_post_mime_types

函式
get_available_post_mime_types ( $type = 'attachment' )
引數
  • (string) $type
    Required:
    Default: 'attachment'
返回值
  • (string[]) An array of MIME types.
定義位置
相關方法
get_available_post_statusesget_post_mime_typesget_post_mime_typeget_allowed_mime_typesget_all_post_type_supports
引入
2.5.0
棄用
-

get_available_post_mime_types: 該函式以一個關聯陣列的形式返回可用的post MIME型別。陣列的鍵是MIME型別,值是相應的人類可讀字串: 該函式不接受任何引數。

為一個給定的文章型別獲取所有可用的文章MIME型別。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function get_available_post_mime_types( $type = 'attachment' ) {
global $wpdb;
$types = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT post_mime_type FROM $wpdb->posts WHERE post_type = %s", $type ) );
return $types;
}
function get_available_post_mime_types( $type = 'attachment' ) { global $wpdb; $types = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT post_mime_type FROM $wpdb->posts WHERE post_type = %s", $type ) ); return $types; }
function get_available_post_mime_types( $type = 'attachment' ) {
	global $wpdb;

	$types = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT post_mime_type FROM $wpdb->posts WHERE post_type = %s", $type ) );
	return $types;
}

常見問題

FAQs
檢視更多 >