Wordpress Logo

According to the support on the WordPress site here embedding GoogleMaps in WordPress is simply a matter of cutting and pasting the Iframe to your post. Simple! Effective? Not so much!

The problem is that if you use the Visual instead of the HTML Post or Page editors the code can get very messed up which is frustrating to say the least. So, a simple and elegant solution:

In your functions.php file (for your relevant theme of course) place the following code

//GoogleMaps Shortcode
function googleMaps($attribs, $content = null) {
extract(shortcode_attribs(array(
“width” => ’640′,
“height” => ’480′,
“src” => ”
), $attribs));
return ‘<iframe width=”‘.$width.’” height=”‘.$height.’” scrolling=”no” frameborder=”0″ marginwidth=”0″ marginheight=”0″src=”‘.$src.’&output=embed></iframe>’;
}
add_shortcode(“googlemap”, “googleMaps”);

Usage within a Page or Post

[googlemap width="200" height="200" src="[url]“]

So, three parameters. Width and Height are optional; if you do not specify the size will default to that specified in the functions.php file. The URL is simply the GoogleMaps share URL.