get_meta_keys() WordPress Function

The get_meta_keys() function is used to retrieve all the available metadata keys for a given post type. It returns an array of metadata keys, or an empty array if no metadata keys are available.

get_meta_keys() #

Returns a list of previously defined keys.


Return

(string[]) Array of meta key names.


Top ↑

Source

File: wp-admin/includes/post.php

function get_meta_keys() {
	global $wpdb;

	$keys = $wpdb->get_col(
		"
			SELECT meta_key
			FROM $wpdb->postmeta
			GROUP BY meta_key
			ORDER BY meta_key"
	);

	return $keys;
}


Top ↑

Changelog

Changelog
VersionDescription
1.2.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More