get_metadata_by_mid
函数
get_metadata_by_mid ( $meta_type, $meta_id )
- 参数
-
-
(string)
$meta_type
Type of object metadata is for. Accepts ‘post’, ‘comment’, ‘term’, ‘user’, or any other object type with an associated meta table.- Required: 是
-
(int)
$meta_id
ID for a specific meta row.- Required: 是
-
(string)
- 返回值
-
- (stdClass|false) { Metadata object, or boolean `false` if the metadata doesn’t exist. @type string $meta_key The meta key. @type mixed $meta_value The unserialized meta value. @type string $meta_id Optional. The meta ID when the meta type is any value except ‘user’. @type string $umeta_id Optional. The meta ID when the meta type is ‘user’. @type string $post_id Optional. The object ID when the meta type is ‘post’. @type string $comment_id Optional. The object ID when the meta type is ‘comment’. @type string $term_id Optional. The object ID when the meta type is ‘term’. @type string $user_id Optional. The object ID when the meta type is ‘user’. }
- 定义位置
-
-
wp-includes/meta.php
, line 787
-
wp-includes/meta.php
- 引入
- 3.3.0
- 弃用
- –
按元ID检索元数据。
function get_metadata_by_mid( $meta_type, $meta_id ) { global $wpdb; if ( ! $meta_type || ! is_numeric( $meta_id ) || floor( $meta_id ) != $meta_id ) { return false; } $meta_id = (int) $meta_id; if ( $meta_id get_row( $wpdb->prepare( "SELECT * FROM $table WHERE $id_column = %d", $meta_id ) ); if ( empty( $meta ) ) { return false; } if ( isset( $meta->meta_value ) ) { $meta->meta_value = maybe_unserialize( $meta->meta_value ); } return $meta; }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。