DISCLAIMER: this post is older than one year and may not be up to date with latest WordPress version.

Google Maps are very useful to show locations on your blog, but they can be a bit tricky to integrate, especially for client or non tech-savvy users. Here is a shortcode that will make Google Maps integration super easy.

To create the shortcode, paste the code below into your functions.php file:

function rockable_googlemap($atts, $content = null) {
               "width" => '940',
               "height" => '300',
               "src" => ''
   ), $atts));
return '<div>
         <iframe src="'.$src.'&output=embed" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" width="'.$width.'" height="'.$height.'"></iframe>
add_shortcode("googlemap", "rockable_googlemap");

Once you saved your function.php file, you can start integrating Google Maps into your posts and pages. To do so, get the url of the map you’d like to display, and use the shortcode as shown below:

[googlemap src="google_map_url"]

or with custom width and height parameters:

[googlemap width="600" height="250" src="google_map_url"]

Thanks to Rockable Themes for the tip!



  1. Is it possible to add custom text to the marker pin through this shortcode?

  2. Adding custom text to marker pin is only possible if you have generated google maps api.
    This is the same shortcode google would give you.
    Only here is that its been made with an array,which you can make widget for example so users can fill this in themselves.

Leave a Comment

Your email address will not be published. Required fields are marked *