Skip to content

Instantly share code, notes, and snippets.

@ignacio-thfoot
Last active February 10, 2021 08:52
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 ignacio-thfoot/973c0c6145542d0c22a0d13b26005d20 to your computer and use it in GitHub Desktop.
Save ignacio-thfoot/973c0c6145542d0c22a0d13b26005d20 to your computer and use it in GitHub Desktop.
ACF Pro - Print all existing field groups
//check that acf pro is installed
if(function_exists('acf_get_field_groups')):
//array with ACF field groups
$aGroups = acf_get_field_groups();
foreach($aGroups as $aGroup):
echo '<pre>';
//show group info
echo "<div><strong>Group ". $aGroup['title'] .":</strong></div>";
var_dump($aGroup);
echo "<div><strong>Fields for ". $aGroup['title'] .":</strong></div>";
//show fields from group
var_dump(acf_get_fields($aGroup['key']));
echo '</pre>';
endforeach;
endif;
@ignacio-thfoot
Copy link
Author

ignacio-thfoot commented Feb 10, 2021

This function will var_dump() all existing field group definitions with names, keys, and fields.

Var Dump output is something like the following:

Group [GROUP NAME]:
array(14) {
["ID"]=>
int(0)
["key"]=>
string(19) "group_600694ecc276c"
["title"]=>
string(22) "Group Name"
["location"]=>
array(1) {
[0]=>
array(1) {
[0]=>
array(3) {
["param"]=>
string(5) "block"
["operator"]=>
string(2) "=="
["value"]=>
string(19) "acf/accordion-block"
}
}
}
["menu_order"]=>
int(0)
["position"]=>
string(6) "normal"
["style"]=>
string(7) "default"
["label_placement"]=>
string(3) "top"
["instruction_placement"]=>
string(5) "label"
["hide_on_screen"]=>
string(0) ""
["active"]=>
bool(true)
["description"]=>
string(0) ""
["_valid"]=>
int(1)
["local"]=>
string(3) "php"
}
Fields for [GROUP NAME]:
array(1) {
[0]=>
array(23) {
["ID"]=>
int(0)
["key"]=>
string(19) "field_6006974ec8f2b"
["label"]=>
string(9) "[Field Label]"
["name"]=>
string(9) "field_name"
["prefix"]=>
string(3) "acf"
["type"]=>
string(8) "repeater"
["value"]=>
NULL
["menu_order"]=>
int(0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment