WordPress has a built in function, the_meta()
, for outputting all custom fields. But this function is limited in that it doesn’t always output all of them. For example, it misses custom fields added by plugins which begin with an _ underscore.
This bit of code uses an alternate function, get_post_custom()
which will return all of them, and display all values. Good for debugging.
<h3>All Post Meta</h3>
<?php
// Get all the data
$getPostCustom = get_post_custom();
foreach($getPostCustom as $name=>$value) {
echo "<strong>" . $name . "</strong>"." => ";
foreach ($value as $nameAr=>$valueAr) {
echo "<br />";
echo $nameAr." => ";
echo var_dump($valueAr);
}
echo "<br /><br />";
}
?>
Ah just what I’ve been looking for. Easy to customize into what you want like a list pulling out all image URLs.
Nice one – thanks!
Excellent, helps a lot!
Looks like I get to be 2016’s comment. Thanks for this, came in handy today!
I’m finding this very handy in 2017, too!
Nice work!
Still useful in 2018. Thanks
I just gotta say, the yearly comments are hilarious.
Still useful in 2021
Sorry my ignorance, where should i enter this code…
Tnx in advance.
You can drop that in any page/post template where you need the custom field content.