Support

Account

Home Forums Front-end Issues ACF with Zurb's Foundation Interchange.js

Helping

ACF with Zurb's Foundation Interchange.js

  • Hi. What I am trying to achieve is to display a static google map image for smaller devices and a normal “active” map for bigger screens. The position of the map is based on some custom fields from ACF. With Foundation it is possible to use multiple php/html files that get swapped on browser resize. So in this case I have 2 files and my markup looks like this.

    <div class="columns" data-interchange="[<?php echo get_template_directory_uri(); ?>/map-small.php, (default)], [<?php echo get_template_directory_uri(); ?>/map-medium.php, (medium)]"></div>

    … inside map-small.php I have these values:

    <?php $location = get_field('location');
    $lat = $location['lat'];
    $lng = $location['lng']; ?>

    but I get a fatal error: Call to undefined function get_field()

    Can someone help me out here?
    Thanks.

  • Hi @ingvi,

    Thanks for the post.

    The error indicates that you are calling the get_field() before ACF has been loaded for the page template.

    I would recommend that you call the function from within the acf/init action.

    This action is described in detail here: https://www.advancedcustomfields.com/resources/acfinit/

    I hope this helps.

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

The topic ‘ACF with Zurb's Foundation Interchange.js’ is closed to new replies.