Hello,
I’m using some custom javascript for my acf frontend forms and was wondering if there is any way to load these scripts only when a page has an acf_form.
Are there any hooks I can attach my enque_scripts to?
Regards, Chris
Enqueue your custom JS and CSS on the hook acf/input/admin_enqueue_scripts
.
Thanks John! I’ve seen this hook, but thought it would only work in wp-admin.
That hook, as I’ve discovered, is run whenever ACF field groups are included on a page, front end or back. Figured it out when I was creating a custom field type and couldn’t get it to work with acf_form().
Hi can you help me with this HOOK.
I want to load specific JS and CSS if there is a specific flexible content on my page and i don’t understand how to use it.
Thanks.
Simon.
I need to write something like that for the css ?
function themeslug_enqueue_style() {
if ( get_sub_field(‘slider’) ) {
wp_enqueue_style( ‘parent-stylesheet’, trailingslashit( get_template_directory_uri() ) . ‘style.css’, false );
}
}
add_action( ‘wp_enqueue_scripts’, ‘themeslug_enqueue_style’ );
Please any help !!
Thanks.