I have been struggling for hours to get Custom Fields to show up in my posts. This is ridiculous: the documentation says these are supposed to display by default but they don't, and the Function Reference doesn't give any useful advice on how to write a function to enable this in the_content();/the loop/whatever. In fact, I can't believe how much of the documentation is useless to the general user, since so little of it has been updated to advise on use of functions in hooks/filters (new in 2.8? 3?), and it's nearly impossible to tell when it's either necessary or redundant because you can't immediately see what the actual function looks like anymore, it's all buried out of view! Arghhh! </rant>
Thanks 1,000 times over if you are able to help. I <3 WordPress but am feeling quite alienated by the new direction the latest versions are taking. I understand the need to separate custom code from functional core, but the separation has added a layer of abstraction that is terribly inaccessible to the motivated learner with little hard code experience.
That out of the way, can anyone offer advice please (besides to give up)? For lack of any better ideas, I decided to simply experiment by inserting this code into single.php, below the_post():
$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 />";
}
$mykey_values = get_post_custom_values('my_key');
foreach ($mykey_values as $key => $value) {
echo "$key => $value ('my_key')<br />";
}
It spits out the following on a single post page:
2 => at (my custom key)
Warning: Invalid argument supplied for foreach() in /home/yada/yada/url/single.php on line 26
Uhhh... the two echo statements are coded differently (they are copied straight from examples in the function reference) but changing the 2nd to match first doesn't seem to matter, since the error is thrown in the line before.