Home Forums Plugin Support WP User Frontend (Free Version) Check custom field before show Google map

This topic is: resolved

This topic contains 6 replies, has 2 voices, and was last updated by  Denis 4 years, 12 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #9021

    Denis
    Participant
    Post count: 165

    Hello,

    I use this shortcode and it works.

    [wpuf-meta name=”bb_geoData” type=”map” height=”250″ width=”450″ zoom=”12″]

    But in some cases there is nothing in the custom field “bb_geoData”. So I need first to check if there is something in the custom field and then show the map.

    How will I do this? It must be something with if…

    Thanks for help,
    Denis

    #9022

    Denis
    Participant
    Post count: 165

    I tried this:

    <?php
    $images = get_post_meta( $post->ID, "bb_geoData", true );
    if ( $images ) {
    ?>
    [wpuf-meta name="bb_geoData" type="map" height="250" width="450" zoom="12"]
    <?php
    }
    ?>

    but then the map is not to see. When I just use the shortcode the map is to see. hmmm…

    #9025

    Tareq Hasan
    Keymaster
    Post count: 2831

    I believe you are using it on your theme. The way you are using it, it'll just display the shortcode, not the map. You could use like this: echo do_shortcode('[wpuf-meta name="bb_geoData" type="map" height="250" width="450" zoom="12"]');

    Or the PHP way,
    [php]
    $map = get_post_meta( $post->ID, "bb_geoData", true );
    if ( $map ) {
    wpuf_shortcode_map( $map );
    }
    [/php]

    #9055

    Denis
    Participant
    Post count: 165

    Hi Tareq,

    I needed to get the ID first…

    <?php
    global $post;
    $map = get_post_meta( $post->ID, "bb_geoData", true );
    if ( $map ) {
        wpuf_shortcode_map( $map );
    }
    ?>

    this is working for me.

    Thanks!

    #9158

    Denis
    Participant
    Post count: 165

    How can I set Height and Width of the map?

    wpuf_shortcode_map( $map );

    Cheers,
    Denis

    #9209

    Tareq Hasan
    Keymaster
    Post count: 2831

    Sometimes it's good to see the PHP code to checkout how it works.

    [php]
    wpuf_shortcode_map( $map, null, array(‘width' => 250, ‘height' => 450, ‘zoom' => 12 ) );
    [/php]

    #15769

    Denis
    Participant
    Post count: 165

    Hey Tareq,
    how can I center the map ?
    Denis

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Check custom field before show Google map’ is closed to new replies.