^ 回到顶部
  • 人生没有定律,每个人都有自己的节奏
  • 本站wordpress建站教程均通过实践后发布,希望对你有帮助
  • 希望你的坚持,都是因为热爱,而不是因为不甘心
  • 8年wordpress建站经验,5星服务品质
  • 那些不愿意让你吃亏的人,才是真正值得你深交的人,也是值得你付出时间的人
  • 阿里云2核2g仅需86元/年

wordpress函数get_metadata_by_mid()用法示例

get_metadata_by_mid( string $meta_type,  int $meta_id )

Get meta data by meta ID


描述


参数

$meta_type

(string)
(Required)
Type of object metadata is for (e.g., comment, post, term, or user).

新用户2核2g仅需86元/年    领取1153套模板    免费cdn流量包    ¥3188礼包

$meta_id

(int)
(Required)
ID for a specific meta row


返回值

(object|false) Meta object or false.


源代码

File: wp-includes/meta.php

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 = intval( $meta_id );
	if ( $meta_id <= 0 ) {
		return false;
	}

	$table = _get_meta_table( $meta_type );
	if ( ! $table ) {
		return false;
	}

	$id_column = ( 'user' == $meta_type ) ? 'umeta_id' : 'meta_id';

	$meta = $wpdb->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;
}

更新日志

Version 描述
3.3.0 Introduced.

相关函数

Uses

  • wp-includes/functions.php:
    maybe_unserialize()
  • wp-includes/wp-db.php:
    wpdb::get_row()
  • wp-includes/wp-db.php:
    wpdb::prepare()
  • wp-includes/meta.php:
    _get_meta_table()

Used By

  • wp-admin/includes/post.php:
    get_post_meta_by_id()
  • wp-admin/includes/ajax-actions.php:
    wp_ajax_add_meta()
  • wp-admin/includes/ajax-actions.php:
    wp_ajax_delete_meta()
  • wp-includes/class-wp-xmlrpc-server.php:
    wp_xmlrpc_server::set_custom_fields()
  • wp-includes/meta.php:
    update_metadata_by_mid()
  • wp-includes/meta.php:
    delete_metadata_by_mid()
  • Show 1 more used by
    Hide more used by


让小雨知道,这篇文章帮到了你
扫码关注微信公众号zs40086(微搜片)随时随地微信看片,抢先福利电影等你来

热门推荐

如有疑问,请前往问答中心反馈!

反馈