Try this code:
<div class="map">
<?php
global $post;
$location = get_field('location', $post->ID);
?>
<div class="acf-map">
<div class="marker" data-lat="<?php echo $location['lat']; ?>" data-lng="<?php echo $location['lng']; ?>"></div>
</div>
</div>
Sometimes in the template you’re loading this you don’t have the post
that the field belongs to, so you can try to fetch it in the global $post
variable.
Related Posts:
- ACF Maps admin error: “For development purposes only” even after supplying api key
- ACF google map not working [closed]
- ACF Map with custom styles field
- Add routes between multiple ACF google maps markers [closed]
- ACF – get fields from group
- How to get “Additional CSS Class” for ACF Gutenberg block
- ACF: get_field() returning false [closed]
- Adding custom fields to the header.php
- How to get_terms() only of terms matching an ACF meta value?
- Query between dates using Date Picker fields
- Advanced custom field – gallery – display one random image
- Showing an ACF field in admin posts dashboard
- Google Places API With ACF [closed]
- Check for the existence of custom field
- ACF Repeater Field, need IF statement for if sub field has content
- Can not create fields in ACF with code
- Advanced Custom Fields – Check if multiple get_fields exist?
- ACF – Custom fields have dissappeared [closed]
- Error in Validate Field with ACF plugin in WordPress
- disable (read only) a field if within a custom post type name
- How to change the page title from functions.php
- Acf Pro repeater field returns null [closed]
- Insert Commas into ACF number field
- How I can check if get_theme_mod is in header or a template part
- Using pre_get_posts for meta value of LIKE comparison on ACF repeater sub field
- WP Rest endpoint with custom post type and ACF Fields
- Advanced custom fields: Customise date picker’s start date (need to choose year 1500 onwards) [closed]
- My get_terms not working for custom fields
- Updating the database with advanced custom fields
- ACF: replace comma with another sign [closed]
- Remove headings option from Wysiwyg editor from ACF in a certain custom post type
- Organize media library into folders and get folders via WP Rest API?
- ACF (Advanced Custom Fields) not updating post or postmeta values
- Remove YoastSEO meta description from output/source [closed]
- Advanced Custom Fields changes get stuck in cache
- WordPress Date with ACF
- ACF Multiple Checboxes Output
- Filter posts by advanced custom field
- Insert Content into Script with Advanced Custom Fields
- Migrating data from ACF to WordPress custom meta boxes
- Get image data from advanced custom field [closed]
- Check for image with same filename but different extension
- ACF: Querying relationship fields with Author
- Querying posts by latitude and longitude to build a Google Maps with several markers
- How to get both image attachment ID and url
- Function wp_enqueue_style was called incorrectly
- ACF Clone Field – Set Default Value
- ACF save json to custom directory not working, default acf-json used instead
- ACF URL behavior, duplicating links
- Advanced Custom Fields oembed only outputs YouTube URL
- Do comparision after updates hooks of acf-fields?
- Importing ACF code in other page templates
- ACF Content with WPML not saving [closed]
- How do you display a custom field on a new page? [closed]
- Hash password field to database, unhash in admin?
- Pulling in content from another page [closed]
- Display category multi-select with Advanced Custom Felds
- Advanced Custom Fields – Check multiple Empty Fields [closed]
- Simple Calendar
- How to only show ACF field if another block is being used?
- ACF Select Field can’t return Array
- Nearby locations using Advanced custom fields, maps?
- Advanced Custom Field Textarea not Showing (ListingPro Theme)
- Using the WP CLI to output the HTML results of calling a post?
- Image is displaying with the url of the image as well
- How to add a custom field for image in “Text and Full Image(text right)” layout?
- Trying to add ACF to authors meta and adding a class at the same time
- Fill up advanced custom field of a custom post type via API REST POST
- Two problems that are likely related to AJAX
- Fancybox3 ACF repeater. URL strip out from the caption field
- ACF – Eliminate unnecessary data and print
- Is it okay to use an ACF field to store a password for a protected area of a page?
- Get values from an advanced custom field
- Front End User Registration – How to Save ACF Values?
- Which is faster: Loading images from the repo, or loading them using ACF Image Content via Media Library
- ACF don’t save the selected value
- help with really simple csv importer
- Advanced Custom Fields Gallery and Flex Slider [reformuled]
- WordPress API response filter by ACF value
- ACF Pro Date Picker not coming through on Loop
- Convert number to date format within an array
- ACF not updating value correctly
- How to display dropdown filters for posts
- Creating a page from acf fields
- Generate a radius search of custom post type locations
- Use an image’s url as argument in update_field function
- Pin to Top Functionality using orderby custom field then event date
- Acf Pro repeater field returns null when call inside foreach
- Relationship field search not retriving posts in admin
- advanced custom fields plugin last input field in new posts
- WordPress loop based on url sting
- Display “Today” Instead of Date for Pubslished Posts
- Advanced Custom Fields repeter field expiration
- Getting “Invalid argument supplied for foreach()” Warning
- WordPress/Timber/Twig – Trying to output checkbox values [closed]
- How to use WordPress to embed a SoundCloud download link?
- upgrading ACF (advanced custom fields) on an old site [closed]
- Generate the post title from ACF fields
- Advanced Custom Fields – Issue with Slick Slider in ACF v6 Block
- How can I update an ACF field in a repeater on post save?