• Resolved Jason Judge

    (@judgej)


    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

Viewing 2 replies - 16 through 17 (of 17 total)
  • Thread Starter Jason Judge

    (@judgej)

    Hehe – I would have done it for four ??

    Seriously through, glad you got it sorted. Software is like that – you type one single character that it does not like, and it won’t forgive you. You always need to make sure you have a way to back out again, and that means backing up files before you change them.

    Oh, and if you have given out access passwords to people you don’t know, make sure you change the passwords once they have done the job.

    yeah, thanx, I’ll try to make back up before I do something else stupid ??

Viewing 2 replies - 16 through 17 (of 17 total)
  • The topic ‘Displaying a map at a shortcode’ is closed to new replies.