Google Static Map using ACF Location Field

The Location Field add-on for Advanced Custom Fields lets you easily create a backend field for users specifying an address. This code allows you to display that address as a static google map.

$location = get_post_meta( get_the_ID(), 'be_address', true );
echo '<p><a href="' . urlencode( $location['address'] ) . '"><img src="' . urlencode( $location['lat'] . ',' . $location['lng'] ). '&zoom=13&size=167x171&maptype=roadmap&sensor=false&markers=color:red%7C' . $location['lat'] . ',' . $location['lng'] . '" /></a></p>';
view raw functions.php hosted with ❤ by GitHub


Bill Erickson

Bill Erickson is the co-founder and lead developer at CultivateWP, a WordPress agency focusing on high performance sites for web publishers.

About Me
Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk