Home › Forums › Add-ons › Flexible Content Field › Check if layout is used › Reply To: Check if layout is used
You could register your script in functions.php and then enqueue it right where you need. So, just as a mere example:
in functions.php
wp_register_script( 'gmaps','https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false', array(), '1.0', true );
and then in your layout code:
elseif( get_row_layout() == 'map' ):
$google_maps = get_sub_field('google_maps');
if( !empty($google_maps) ):
wp_enqueue_script('gmaps');
This will load google’s .js in footer just when you need it.
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.