<?php
$custom_fields = get_post_custom(72);
$my_custom_field = $custom_fields['my_custom_field'];
foreach ( $my_custom_field as $key => $value )
echo $key . " => " . $value . "<br />";
?>
Ok. So I type my custom field in place of “my_custom_field” and use $post->ID; instead of the post number, to get the proper post ID inside the loop..
It worked for me to get all values from one custom field separately.
What I want to do is get all values from all custom fields, except specific custom fields. Example;
<?php the_meta(); ?>
That will give me all custom key values, but I would like it not to fetch key_5 for example.
Cheers
Can you be a little clearer about what it is that the function above is not doing for you?..
As far as i can make out, you just need to exclude a particular key.. is that right? Or an i misunderstanding?
I think what you want is two nested loops:
<?php
$custom_fields = get_post_custom(3);
foreach ( $custom_fields as $key => $values) {
if ($key == 'key_5') continue;
foreach ( $values as $value) {
echo $key . " => " . $value . "<br />";
}
}
?>