Support

Account

Home Forums General Issues Conditionally load Google Maps script if the map field is present on any page

Helping

Conditionally load Google Maps script if the map field is present on any page

  • I have maps loaded via the Map field on many pages of different post type and also from different post templates (I mean the post templates in this sense).

    Because of the sheer variety of map field appearance conditions, is there any way/hook that would allow to enqueue the map script on any page if the ACF map field gets loaded there?

  • @exove you could put this in your header:

    
    if (get_field('location')) :
      wp_enqueue_script('...');
    endif;
    

    …where location is the name of your field

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

The topic ‘Conditionally load Google Maps script if the map field is present on any page’ is closed to new replies.