Support » Plugin: Embed Google Map » How to add shortcode to template

  • Resolved sagelike

    (@sagelike)


    Hi there,

    I’m trying to use the shortcode directly on template with this code:

    <?php echo do_shortcode(‘[google_map version=”classic” lang=”en” link=”yes” width=”100%” height=”240″]’.$address.'[/google_map]’); ?>

    How do I use the ‘.$address.’ part of the code?

    As I understand shortcodes, I can replace $address with ‘.$123 Someplace Rd.’ but this breaks the page whenever I try it, i.e.:

    <?php echo do_shortcode(‘[google_map version=”classic” lang=”en” link=”yes” width=”100%” height=”240″]’.$123 Someplace Rd., Calgary, Alberta TAT 1A1.'[/google_map]’); ?>

    The above breaks the page. Nothing loads and it’s blank. As soon as I add a number, it breaks.

    I’m not a programmer and I’m obvious using .$address. incorrectly.

    Any help would be appreciated.

    Thanks
    G

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

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

    (@petkivim)

    Hi,

    At first, sorry for the late answer. The problem is that quotation marks are missing around the address string (and ‘$’ sign is not needed). This should work.

    <?php echo do_shortcode('[google_map version="classic" lang="en" link="yes" width="100%" height="240"]'.'123 Someplace Rd., Calgary, Alberta TAT 1A1'.'[/google_map]'); ?>

    Another alternative is to assign the address string to a variable. E.g.

    <?php
    $address = '123 Someplace Rd., Calgary, Alberta TAT 1A1';
    echo do_shortcode('[google_map version="classic" lang="en" link="yes" width="100%" height="240"]'.$address.'[/google_map]');
    ?>

    Best regards,
    Petteri

Viewing 1 replies (of 1 total)
  • The topic ‘How to add shortcode to template’ is closed to new replies.