Preferred way to include Advanced Custom Fields in a plugin?

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 Comment