So I am building a plugin for a site that is already using Advanced Custom Fields (ACF). I wonder what would be the best way to include ACF in my plugin? The site is already using ACF, so is it possible to include ACF from the plugin directory or should I include ACF again?

3 Answers
3

If ACF (or any other plugin) is active on the site you do not need to include its files as they are all being included in the wordpress initialization process. The only tricky part is that you don’t know the order in which files are included and yours might be included before the ACF files are included, therefor you should probably wait for the init action or even later action before using it.

Side note: ACF provides GUI for custom fields, but if you just need to use the data it is better not to rely on its API and query using the get_post_meta API. This will result in better software modularization and hopefully a more maintainable site.

Leave a Reply

Your email address will not be published. Required fields are marked *