Home › Forums › General Issues › The right way to use ACF in a theme › Reply To: The right way to use ACF in a theme
Ok, I have answered the question by myself. The mistake was the missing include ACF plugin main file.
I could solved all of my issues with including this path:
include_once( get_stylesheet_directory() . '/inc/plugins/acf/acf.php' );
So this is the right way:
STEP 1: Download the ACF PRO plugin ZIP file
STEP 2: Unzip the ACF PRO plugin ZIP file
STEP 3: Upload the unzipped ACF PRO package to your theme materials folder like ../your-theme/inc/plugins/acf/[here is the unzipped package located]
STEP 4: Add the following code to your theme functions.php to load the ACF PRO plugin from the theme folder: include_once( get_stylesheet_directory() . '/inc/plugins/acf/acf.php' );
STEP 5: Add the “1. customize ACF path” and “2. customize ACF dir” code from my first post to the functions.php and change the path to your theme located ACF PRO folder.
STEP 6: Add the following code to your theme functions.php to load your custom field groups, if you want to work with all the fields from the PHP exported file
include_once( get_stylesheet_directory() . ‘/inc/acf-field-groups.php’ );
This is the best way to add ACF PRO to your theme, without installing the plugin in the main way by the user. So the user will get no notice about a newer version of ACF and the theme developer can control the ACF version with the included ACF theme folder.
This is great 🙂
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.