Friday, July 12, 2013

How to Dump All Custom Fields in your WordPress Website

the_meta() function of WordPress output 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. Which is very Good for debugging.

<h3>Dump Post Meta</h3>

<?php $getPostCustom=get_post_custom(); // Get all the data ?>

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 />";


Disqus Comments