Support

Account

Home Forums ACF PRO Map field CPT

Solved

Map field CPT

  • Hi there.

    I’m new with using the Map Field. Trying to just make one map field so my client can set his address in the CPT and I want to display that map in the frontend. Nothing fancy, just one marker on the map.

    I’ve worked with the docs and put the jQuery in the footer.php (<script></script), didn’t enqueue but I can see it in view-source. (the helpers script) and I’ve set my API key within a small plugin of me with other stuff. API key works.

    In my page template I got this:

      <?php
    
    $location = get_field('locatie');
    
    if (!empty($location)):
    ?>
    <div class="acf-map">
    	<div class="marker" data-lat="<?php echo $location['lat']; ?>" data-lng="<?php echo $location['lng']; ?>"></div>
    </div>
    <?php endif; ?>

    Two issues:

    1) Backend: when saving the post the field doesn’t show what I’ve entered and the map is just on the normal location/zoom. Normal behaviour? Any way to get this to show what I’ve entered?
    2) Frontend: php error:
    ( ! ) Warning: Illegal string offset 'lat' in /app/public/wp-content/themes/HappyStudents/single-panden.php on line 27 Call Stack #TimeMemoryFunctionLocation 10.0000362720{main}( ).../index.php:0 20.0000363008require( '/app/public/wp-blog-header.php' ).../index.php:17 30.07055841160require_once( '/app/public/wp-includes/template-loader.php' ).../wp-blog-header.php:19 40.07225858872include( '/app/public/wp-content/themes/HappyStudents/single-panden.php' ).../template-loader.php:74 A" data-lng="

    Jeroen

  • Since I’ve looked further on this forum I’ve seen I got the same name twices!

    Let me see if I can work both of this issues out.

    Edit: this was ridiculous stupid, but fixed my issues.

    Jeroen

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

The topic ‘Map field CPT’ is closed to new replies.