custom field – How can I only run acf_add_local_field() once?


We are writing a plugin that depends on ACF. But while defining our custom fields via PHP, it occurs to me — won’t those acf_add_local_field functions run on every page load if we define them within something like the acf/init hook? Even if it won’t cause an issue (i.e. ACF will just recognize they exist already and exit gracefully), that seems inefficient.

I was thinking perhaps of doing it during the plugin activation hook. Is there a “best practice” for registering new custom fields such that the code to do so doesn’t get called over and over?

armadadrive 4 weeks 2021-08-23T15:53:55-05:00 0 Answers 0 views 0

Leave an answer