Display Google map on single or author page

As you already know WP User Front-end allows you to insert google map on your front-end post form and registration form as well.

Now, many people face difficulty to show google map on their single page or author page. We have documentations here . Still i will go though in details.

Google map

To show google map or any custom fields i will recommend you to edit your theme template file directly. Specially, when you allow your users to post topics/posts and publish them automatically without modification.

Where is short-code? :

Well, if you use WPUser front-end then there is a short-code available to make life easier!

[wpuf-meta name="meta_key_name" type="map"]

here meta_key_name is same as your form google map's meta key.

You can control map size with parameters. examples:

[wpuf-meta name="meta_key_name" type="map" height="250" width="450" zoom="12"]

You can set – Height,Width,zoom level etc.

using short-code is easy process unless you allow your users/guests to post on your site. Cause, definately you will not like to edit their posts right?

Thats where template modifications come.

Show on single post:

To show google map on a single page open your single.php file with a editor. then use this code where you want to show the map:

Again, make sure your meta_key name match with “location” or change is accordingly.

Show on Author page:

To show author location on author page, open author.php file. and use this code –

$location = get_user_meta( $curauth->ID, 'meta_key', true );
wpuf_shortcode_map( $location );

Change “meta_key” with right meta_key.

Now to change map size with perameters replace wpuf_shortcode_map( $location ); with

wpuf_shortcode_map( $location, false, array('width' => 450, 'height' => 250, 'zoom' => 12) );

Hope you will find it useful. Also, sometimes some theme styles can break your page style. so, make sure your page looks good. If you are our existing customer always welcome to open support topic via forum or comment bellow.

3 Comments

  • Jyl

    Jyl

    Question:
    $location = get_user_meta( $curauth->ID, ‘meta_key’, true );
    puf_shortcode_map( $location, false, array(‘width’ => 450, ‘height’ => 250, ‘zoom’ => 12) );

    How will the code above detect the address if im using a custom user_meta for the street, city, state and country??

  • Jyl

    Jyl

    Oops.. sorry I just figured it out, address must be filled up from the back-end. Btw. great plugin

  • Andreas Kviby

    Andreas Kviby

    The most wanted would be for us to show the vendors on a map, all of them together.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.