Home Forums Backend Issues (wp-admin) Filter display options for field group?


Filter display options for field group?

  • Hi there

    I’m wondering if there is a way I can filter the display options for a field group, to dynamically modify the hide_on_screen array.

    Bascially, I’m using multiple field groups on various locations, but I notice that only the first registered field group’s display options are honoured. I have a few fields whose rules need to take priority over others, so I’m looking for a way to either, a) change the order of registered field groups on a particular page, or b) filter all the field groups options to ensure they are the same where necessary.


  • Hi @mishtershmart

    Good question. I haven’t tried to do this, so I’m not 100% if it is possible, but there are 2 filters which you may find useful.

    You will find all the source code in ‘core/controllers/field_group.php’.

    The first filter is ‘acf/get_field_groups’
    Hooking into this may allow you to re-order the array and place your field group in question at the start of the array. ACF will then use it’s CSS over any others

    The other is ‘acf/field_group/get_options’
    This will allow you to customize the hide_on_screen array for any field group. Perhaps you could override all field groups settings?


  • Thanks @elliot

    That definitely did the trick. Both filters and their respective techniques (reordering fields or modifying the hide_on_screen array) work just fine. I opted to use the acf/field_group/get_options filter though, along with some conditional checks for the relevant page/post/template to achieve the desired result.

    By using this technique, we don’t really have to worry about setting display options when configuring the field, as we can control the settings on a post/page/template basis instead.



  • Mishtershmart,

    Can you share a snippet of how you did this? I need to do this exact thing, where I have a default field group that is on every page and needs to be right after the title of the CPT, but I need other field groups’ options to always take precedence. I’m not following how you achieved it.

  • @watermelonkid,

    It’s been so long since I did this, I can’t recall where I used it. But, if you hook into that filter and dump out whatever is passed into it, you’ll be able to analyse the data structure and unset anything you don’t need in a given context.

    Hope that helps.

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Filter display options for field group?’ is closed to new replies.