Displaying a map at a shortcode
-
I needed to display the map in different places on various pages, so I created a shortcode tag to indicate where it is displayed. The code that sits in the theme’s functions.php is:
function pronamictag_func($atts) { extract(shortcode_atts( array( 'width' => 500, 'height' => 300, ), $atts )); return pronamic_google_maps(array( 'width' => $width, 'height' => $height, 'echo' => false, )); } add_shortcode('pronamic', 'pronamictag_func');
With this I can insert a shortcode tag anywhere in the content to display the map, like this:
[pronamic]
or
[pronamic width=600 height=200]
It would be nice if the width could be expressed as a percentage, but it is always interpreted as pixels.
— Jason
- The topic ‘Displaying a map at a shortcode’ is closed to new replies.