<?php$groups=acf_get_local_field_groups();$json=[];foreach($groupsas$group){// Fetch the fields for the given group key$fields=acf_get_local_fields($group['key']);// Remove unecessary key value pair with key "ID"unset($group['ID']);// Add the fields as an array to the group$group['fields']=$fields;// Add this group to the main array$json[]=$group;}$json=json_encode($json,JSON_PRETTY_PRINT);// Optional - echo the JSON data to the pageecho$json;die;
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.