1
votes

This what Im doing:

  1. I have 2 ACF fields inside the option page. test and test_my_group
  2. I have 1 group inside my option page name my_group
  3. The field test_my_group located inside my_group ACF group.

My Problem is:

  1. I can easily get the test field value inside Timber Tiwg template using the tag {{ options.test }}
  2. I fail to get the test_my_group value as its inside the group my_group
  3. If I move the field test_my_group out side my_group, Now I can use {{ options.test_my_group}} without any problem.

=== In normal CPT and Posts, I dont have any problem caling the field value if located inside a ACF group by setting the group first then calling the child filled.

{% set group = post.meta('group') %}
{{ group.first_field }}
{{ group.second_field }}

My Question IS:

How to call the group sub-fields of an ACF group inside option page?

1

1 Answers

1
votes

I did not found any related documentation describing how to get ACF options groups sub field values using Timper. However,

When I look again in the normal group fields Twig function and tags:

{% set group = post.meta('group') %}
{{ group.first_field }}
{{ group.second_field }}

I noticed the . after group. And its give a hint with the answer.

The answer to my previous question is:

This tag will fetch the group sub fields value from: group array and can be use for multiple sub group level inside options page like:

  1. Options => Group => Sub fields.
  2. Options => Group => Group => Sub fields.
  3. etc ....

EXAMPLE 1

If we have the exact same scenario of my question this tag should work to get the ACF options group sub field value:

{{ options.GROUP_SLUG.SUB_GROUP_SLUG}}

So in my case it was:

{{ options.my_group.test_my_group}}

EXAMPLE 2

  1. In the options page we have group with slug group_1
  2. In this group we have other group with the slug group_2 inside group_1
  3. In the group_2 we have sub field name group_2_field.

In this case we should use:

 {{ options.GROUP_1.GROUP_2.GROUP_2_FIELD}}

Which should be in EXAMPLE 2:

{{ options.group_1.group_2.group_2_field}}

I tested and its working perfect, Also I decided to share this with other so they may use it as hint for something better.