Get array of custom fields in post
-
I have a lot of custom fields in my posts. Rather than using
echo get_post_meta($post->ID, 'my_custom_field', true);for each custom field is it possible to create an array of all my custom fields and retrieve the custom field name and value for each one?
I came across the following code which is close to what I need but it retrieves the key and id..
`$custom_field_keys = get_post_custom_keys();
foreach ( $custom_field_keys as $key => $value ) {
$valuet = trim($value);
if ( ‘_’ == $valuet{0} )
continue;
echo $key . ” => ” . $value . “<br />”;
}`
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Get array of custom fields in post’ is closed to new replies.