Note: This method no longer works as intended due to changes in WordPress and Google maps. However, if you paste the iframe information from the Google maps page, WordPress automatically converts the frame to its own shortcode for you. At least, it’s supposed to work that way.
Adding Google maps to your WordPress installation isn’t actually difficult at all. Simply add this to your functions.php file and call using the resulting
[ googlemap ] shortcode.
//Google Maps Shortcode
function fn_googleMaps($atts, $content = null) {
extract(shortcode_atts(array(
"width" => '640',
"height" => '480',
"src" => ''
), $atts));
return '';
}
add_shortcode("googlemap", "fn_googleMaps");
And then inside the post itself:
[googlemap width="200" height="200" src="[url]"]
That support article seems to refer to WordPress.com-hosted blogs, rather than independent WordPress installations, just for the record.
It is indeed a WordPress.com reference, you’re correct. The same information did once apply to both, but it’s just another one of those things that the WordPress CMS has phased out over time, due to “security” issues.
Oh, I see what you mean now.
I spent some time this afternoon tinkering with a variation on that snippet posted on digwp.com and figured out how to make it work again on an independent WP installation, so hooray!
Here is my fix for this shortcut code in the functions.php file, in case it helps anyone…
———————
//Google Maps Shortcode
function fn_googleMaps($atts, $content = null) {
extract(shortcode_atts(array(
"width" => '490',
"height" => '500',
"src" => ''
), $atts));
return '<iframe width="'.$width.'" height="'.$height.'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'.$src.'&output=embed"></iframe> <br /><a href="'.$src.'&source=embed" >View Larger Map</a>
';
}
add_shortcode("googlemap", "fn_googleMaps");
Thanks, KJ.
Thanks. KJ!!!