WordPress at a glance
function is not described

get_metadata_by_mid() WP 3.3.0

Get meta data by meta ID

  • Global. wpdb. $wpdb WordPress database abstraction object.
Hooks in function
Return

Object/false. Meta object or false.

Usage

get_metadata_by_mid( $meta_type, $meta_id );
$meta_type(string) (required)
Type of object metadata is for (e.g., comment, post, term, or user).
$meta_id(int) (required)
ID for a specific meta row

Code of get metadata by mid: wp-includes/meta.php VER 5.1.1

<?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';

	/**
	 * Filters whether to retrieve metadata of a specific type by meta ID.
	 *
	 * The dynamic portion of the hook, `$meta_type`, refers to the meta
	 * object type (comment, post, term, or user). Returning a non-null value
	 * will effectively short-circuit the function.
	 *
	 * @since 5.0.0
	 *
	 * @param mixed $value    The value get_metadata_by_mid() should return.
	 * @param int   $meta_id  Meta ID.
	 */
	$check = apply_filters( "get_{$meta_type}_metadata_by_mid", null, $meta_id );
	if ( null !== $check ) {
		return $check;
	}

	$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;
}