Show All Post Meta Keys and Values for a Post in WordPress

If you wanted to see all the post meta keys and values for a post,page or custom post type in WordPress you can either see them in the database in the wp_postmeta table or you could use the get_post_meta function to retrieve all the post meta or a specific key.

To output the data to the head of the page you can just hook the output to wp_head…

add_action('wp_head', 'output_all_postmeta' );
function output_all_postmeta() {

	$postmetas = get_post_meta(get_the_ID());

	foreach($postmetas as $meta_key=>$meta_value) {
		echo $meta_key . ' : ' . $meta_value[0] . '<br/>';
	}
}

Now you can see a complete list and all the keys with or without meta values.

2 comments

  • I didn’t Understand properly. Where to add this action? and where the meta key will be visible?

Leave your comment