has_meta()WP 1.2.0

Returns meta data for the given post ID.

No Hooks.

Return

Array[]. Array of meta data arrays for the given post ID.

Usage

has_meta( $postid );
$postid(int) (required)
A post ID.

Notes

  • Global. wpdb. $wpdb WordPress database abstraction object.

Changelog

Since 1.2.0 Introduced.

has_meta() code WP 6.5.2

function has_meta( $postid ) {
	global $wpdb;

	return $wpdb->get_results(
		$wpdb->prepare(
			"SELECT meta_key, meta_value, meta_id, post_id
			FROM $wpdb->postmeta WHERE post_id = %d
			ORDER BY meta_key,meta_id",
			$postid
		),
		ARRAY_A
	);
}