Site icon Google Maps Widget

Using the shortcode

While the free version of Google Maps Widget allows you to display a map in any sidebar within your active theme, the PRO version allows you to use shortcodes as well. By using an automatically generated shortcode, you can easily display your custom map anywhere on the site.

The Shortcode:

If you have already created a widget, the shortcode has been created as well:

  1. Navigate to Appearance -> Widgets
  2. Find the GMW widget where you have created your map
  3. Open the widget and find the fourth, Shortcode tab
  4. Copy the shortcode which will look something like this:
    [gmw thumb_width="620" thumb_height="620" id="1"]

Now you can use the shortcode to display the map anywhere in your posts, pages or in any WordPress template.

Please note that your theme might style the widget in the post as if it is placed in a sidebar. In that case, use the div.gmw-shortcode-widgetclass to target the shortcode and make necessary changes via CSS.

Use the shortcode in templates:

To use the shortcode in a post or a page, it will be enough to copy and paste it in the editor. But if you want to use the shortcode in template files (for example, footer.php file), you will have to add additional code in order to execute it:

    1. Open footer.php file or any other template file
    2. Copy and paste the following code:
<?php echo do_shortcode('[gmw thumb_width="620" thumb_height="620" id="1"]'); ?>
  1. Replace the widget ID with the one from your own shortcode
  2. Save changes

Using the hidden sidebar:

This sidebar will allow you to customize your map so that you can only use it with shortcode. A hidden sidebar won’t display your map as a widget. If you don’t need one, you can always remove it from the admin area.

  1. Navigate to Appearance -> Widgets
  2. Locate the Google Maps Widget PRO hidden sidebar
  3. Drag the GMW widget to the hidden sidebar
  4. Customize the map
  5. Open the fourth, Shortcode tab
  6. Copy and paste the shortcode where you want to show the map

*Please note that a shortcode can be used only once per posts/page. If you want to show multiple maps on one page, you will have to create additional widgets and use different IDs in shortcodes.

Exit mobile version