Output All Custom Field Data In A Loop – Including ACF Fields

During a recent build using Gutenberg editor, I needed to check the output of custom fields in a post as the fields weren’t displaying when getting called.

To output all custom fields in a post loop, you can use this handy snippet to show all fields and it’s data. This also works for ACF (which are just normal custom fields) and is the equivalent to a var_dump of a $post variable.

$OutputAllCustomFields=get_post_custom(); // Get all the data
foreach($OutputAllCustomFields 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 />";
}

 

 

Useful post? Share it

Leave a Reply

Your email address will not be published. Required fields are marked *