Home › Forums › General Issues › Load JS script after ACF › Reply To: Load JS script after ACF
The action you’re using, 'acf/input/admin_footer'
only fires on the admin page where you edit the field groups. (Perhaps this is not what you want)
To enqueue a script that fires on every admin page and loads after ACF, use this:
wp_register_script('custom-acf-js', get_template_directory_uri() . '/library/scripts/script-js.js', ['acf-input'], '1.0.0', true);
wp_enqueue_script('custom-acf-js');
The five parameters in the 'wp_register_script'
are:
wp_register_script(UNIQUE_NAME, FULL_URL_OR_PATH, DEPENDENCIES_ARRAY, VERSION, LOAD_IN_FOOTER_BOOLEAN);
wp_enqueue_script('custom-acf-js')
as seen here: https://developer.wordpress.org/reference/functions/wp_register_script
Putting ['acf-input']
in the dependencies array parameter tells the script it needs to wait until ‘acf-input’ has loaded first, which is ACF’s js script.
If you want the script to load in other ways, on other pages, ACF also has other actions you can hook into, take a look here for those: https://www.advancedcustomfields.com/resources/#actions
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.