Home Forums General Issues Field Groups and Location Rules


Field Groups and Location Rules

  • Hello,

    Is there a way in which field groups can contain slight variations, based on Location Rules, or something similar?

    I’m wanting to consolidate a number of related field groups into one, using tabs, to improve the user experience in WordPress administration.

    However, there are some fields, belonging to these fields groups, which are specific to certain types of posts and are presently applied to those using Location Rules.

    As I see it, those fields which are currently applied with Location Rules cannot be consolidated, effectively making any meaningful consolidation of related fields groups practically impossible.

    I do not want to duplicate field groups, as ongoing maintenance would be negatively impacted.

    Any help greatly appreciated.


    Paul S.

  • You are correct. You cannot limit where individual fields are shown, only entire field groups.

    It is possible to limit where a specific field is used by using an acf/prepare_field filter to remove fields that should not be shown. You would need to use the “field key” variant of the filter and you would need to determine for yourself when the field should be shown or not.

    In all likely hood it would mean saving the post to become effective. For example, if a location rule is based on a taxonomy term then the post would need to be saved with that taxonomy term before you would be able to test for that taxonomy in your filter function. The same would apply to any setting that is generally controlled by WP.

    This could be overcome by moving all WP settings into custom fields, you could then use conditional logic based on these new custom fields instead of the above filter. However, this would mean creating an acf/save_post action to convert all of the new controls into WP setting when the post is saved. This may also not be possible in all cases.

  • Thanks as always, John.

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

You must be logged in to reply to this topic.