Skip to content

Instantly share code, notes, and snippets.

@grayayer
Created March 21, 2017 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grayayer/82d3edcfdbf4774e394c7305aa98444a to your computer and use it in GitHub Desktop.
Save grayayer/82d3edcfdbf4774e394c7305aa98444a to your computer and use it in GitHub Desktop.
Dump All Custom Fields
/*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 $getPostCustom=get_post_custom(); // Get all the data ?>
<?php
foreach($getPostCustom as $name=>$value) {
echo "<strong>".$name."</strong>"." => ";
foreach($value as $nameAr=>$valueAr) {
echo "<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
echo $nameAr." => ";
echo var_dump($valueAr);
}
echo "<br /><br />";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment