Support » Fixing WordPress » Load Google Map Using Custom Field

  • Hi! I want to show up google maps on different posts based on the custom field data which will be containing google-maps address such as http://maps.google.com/maps?q=Kathmandu,+Nepal&hl=en&z=13. What plugin should I use for this? Or what modification should I make to the theme in single.php? Any help appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Really depends on how you want the gm data displayed. For example, if you want to show just a link to the gmap, as per your URL above, you’d want something like the followingin single.php (not tested!):

    <?php $gmap_url = get_post_meta("Google Maps URL", $post->ID, true);
    If($gmap_url){ ?>
    <a href="<?php echo( esc_url( $gmap_url ) ); ?>">see map</a>
    <?php } ?>

    Then define your map URL in the custom field “Google Maps URL” in your post.

    Thanks for your reply. I want to display the javascript map using that url. There are plugins that does this work (if provided shortcode [map:google-map-real-url] in the posts/pages, the javascript scrollable maps appear. You can see it working on my site http://chitwan.info. But I want the maps to be displayed somewhere else rather than in the post, that’s why I want it to work on the theme but unfortunately the shortcode only works for the post/pages. I am currently using http://wordpress.org/extend/plugins/google-maps/ plugin to display the map using the url in the post. Thanks again. Any more solutions? Really appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Load Google Map Using Custom Field’ is closed to new replies.