Check custom field before show Google map

This topic contains 6 reply and 2 voices, and was last updated by Denis 10 years, 2 months ago
Viewing 6 Posts - 1 through 6 (of 6 total)
Author Posts
October 15, 2013 at 11:12 am 9021
Denis 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
October 15, 2013 at 11:25 am 9022
Denis Denis

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…

October 15, 2013 at 5:09 pm 9025
Tareq Hasan Tareq Hasan

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]

October 16, 2013 at 12:16 pm 9055
Denis Denis

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!

October 18, 2013 at 1:54 pm 9158
Denis Denis

How can I set Height and Width of the map?

wpuf_shortcode_map( $map );

Cheers,
Denis

October 19, 2013 at 11:41 pm 9209
Tareq Hasan Tareq Hasan

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]

February 24, 2014 at 12:43 am 15769
Denis Denis

Hey Tareq,
how can I center the map ?
Denis

Viewing 6 Posts - 1 through 6 (of 6 total)