Skip to content

Instantly share code, notes, and snippets.

@webaware
Created April 2, 2014 04:33
Show Gist options
  • Save webaware/9927981 to your computer and use it in GitHub Desktop.
Save webaware/9927981 to your computer and use it in GitHub Desktop.
Set map address from custom field "Street Address" if page/post has one, on Flexible Map plugin for WordPress
<?php
/*
Plugin Name: Flxmap Custom Address
Plugin URI: https://gist.github.com/webaware/9927981
Description: Set map address from custom field "Street Address" if page/post has one
Version: 1
Author: WebAware
Author URI: http://webaware.com.au/
@ref http://wordpress.org/support/topic/flexiblemap-address-using-data-from-custom-field
*/
/**
* @param array $attrs shortcode attributes for map
* @return array
*/
add_filter('flexmap_shortcode_attrs', function($attrs) {
global $post;
if ($post) {
$address = get_post_meta($post->ID, 'Street Address', true);
if ($address) {
$attrs['address'] = $address;
}
}
return $attrs;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment