Home Forums Add-ons Flexible Content Field Check if layout is used


Check if layout is used

  • Hi.

    I have a Flexible Content Layout to display a Google Map field.
    So in my functions.php I added this:
    wp_enqueue_script( 'google-map-api', '', array(), '3.0.0', true );

    Now I only want to load this if the layout ‘Google Map’ is used. How can I check this?


  • 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','', 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) ):

    This will load google’s .js in footer just when you need it.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Check if layout is used’ is closed to new replies.