Loading...
Home Picture
Code

Show Advanced Custom Fields specific group as ARRAY on frontend by group ID

Scroll Down

Advanced Custom Fields is one of the best WordPress plugin that help to add additional meta data for post, page, post type. It also help to create theme option or additional user meta field vary easily.

It is easy to use and really well documented but for advance uses sometime we need to use specific group that we created on the Custom field group.

In this case you will need to get that specific field group ID. Check the screenshot below to get the group ID..

 

Now to get that specific group data you will need to use two ACF pre defined function.

  • acf_get_field_group()
  • acf_get_fields()

acf_get_field_group support needs ID, key or name. acf_get_fields support two parameter fields or parent (optional).

Please take a look at the below code to get the data of a specific ACF group data.

if(function_exists('acf_get_field_group') && function_exists('acf_get_fields')){
$aar = acf_get_field_group(341);
$fields = acf_get_fields( $aar );
print_r($fields);
}

I hope it will help… Thanks