Created
April 2, 2014 04:33
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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