Load Google Map Using Custom Field (3 posts)

  1. sushil
    Posted 4 years ago #

    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.

  2. SpankMarvin
    Posted 4 years ago #

    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.

  3. sushil
    Posted 4 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic