Another tool – show the keys for all custom fields in a WordPress post

Finally fixed it!

I found this referenced on this WordPress codex page:

$custom_field_keys = get_post_custom_keys();
foreach ( $custom_field_keys as $key => $value ) {
$valuet = trim($value);
if ( '_' == $valuet{0} )
echo $key . " => " . $value . "

This will display a list of all the keys in custom fields on the current post. Then once you know the key name you need, you can retrieve and publish it – this is one way to handle that:

$myCFValue = get_post_meta($post->ID, 'myKey');
if (isset($mCFValue[0])) {
echo "My Custom Field Value: ".$myCFValue[0];

Leave a Reply

Your email address will not be published. Required fields are marked *