Support » Plugin: Embed Google Map » Template shortcode variable with query

  • Hi

    I tried adding a mysql query for the $address variable to call in the shortcode but it’s not working:

    ('[google_map version="classic" lang="en" link="yes" width="200" height="200"]'.$address.'[/google_map]');

    This was the query I created in the variable:

    $address = "select address from map where Title in (select post_title from wp_posts where ID = '29') AND active='1'";

    Can someone help me with this please.

    https://wordpress.org/plugins/embed-google-map/

Viewing 1 replies (of 1 total)
  • Plugin Author petkivim

    (@petkivim)

    Hi,

    You should fetch the address from the database before adding the shortcode. The below syntax for the db query is not correct, but you should get the idea in which order things should done.

    $sql = "select address from map where Title in (select post_title from wp_posts where ID = '29') AND active='1'";
    $addresses = $wpdb->get_results($sql, ARRAY_N);
    
    ('[google_map version="classic" lang="en" link="yes" width="200" height="200"]' . $addresses[0]['address'] . '[/google_map]');
Viewing 1 replies (of 1 total)
  • The topic ‘Template shortcode variable with query’ is closed to new replies.