MapPress Maps for WordPress Shortcodes

Below, you’ll find a detailed guide on how to add the MapPress Maps for WordPress Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the MapPress Maps for WordPress Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the MapPress Maps for WordPress Plugin and the shortcodes it provides:

Plugin Icon
MapPress Maps for WordPress

"MapPress Maps for WordPress is a powerful plugin that allows you to easily integrate Google Maps into your site. It enhances your WordPress experience with interactive map features."

★★★★☆ (141) Active Installs: 50000+ Tested with: 6.3.2 PHP Version: 7.0
Included Shortcodes:
  • [mappress]
  • [mashup]

MapPress Maps for WordPress [mappress] Shortcode

The ‘mappress’ shortcode from the MapPress Google Maps for WordPress plugin is used to display a specific map or the first map attached to a post. It checks if a ‘mapid’ attribute is set, if so, it displays that map. If not, it retrieves the first map related to the current post. This shortcode is versatile, allowing for customized map displays on your site.

Shortcode: [mappress]

Parameters

Here is a list of all possible mappress shortcode parameters and attributes:

  • mapid – Specifies the unique identifier of the map to be displayed

Examples and Usage

Basic example – A simple implementation of the Mappress shortcode to display a map by referencing the map’s ID.

[mappress mapid=1 /]

PHP Function Code

In case you have difficulties debugging what causing issues with [mappress] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('mappress', array(__CLASS__, 'shortcode_map'));

Shortcode PHP function:

function shortcode_map($atts='') {
		global $post;

		if (self::is_admin() || is_feed())
			return;

		$atts = self::scrub_atts($atts);

		// Determine what to show
		$mapid = (isset($atts['mapid'])) ? $atts['mapid'] : null;

		// On archive pages, $post isn't set
		if (!$mapid && !$post)
			return;

		if ($mapid) {
			// Show map by mapid
			$map = Mappress_Map::get($mapid);
		} else {
			// Get the first map attached to the post
			$maps = Mappress_Map::get_list('post', $post->ID);
			$map = (isset ($maps[0]) ? $maps[0] : false);
		}

		if (!$map)
			return;

		return $map->display($atts);
	}

Code file location:

mappress-google-maps-for-wordpress/mappress-google-maps-for-wordpress/mappress.php

MapPress Maps for WordPress [mashup] Shortcode

The ‘mashup’ shortcode in the MapPress Google Maps for WordPress plugin is used to display a mashup of multiple maps. This shortcode checks if the user is an admin or if the page is a feed. If not, it scrubs the attributes and generates a mashup map.

Shortcode: [mashup]

Examples and Usage

Basic example – The following shortcode calls up the ‘mashup’ function with no additional parameters. This will return a mashup based on the default settings.

[mashup /]

Advanced examples

In this example, we’re adding a couple of parameters to the shortcode. The ‘id’ parameter specifies the ID of the mashup we want to display, while the ‘title’ parameter defines the title of the mashup.

[mashup id="1" title="My First Mashup" /]

Here’s another advanced example. We’re still using the ‘id’ and ‘title’ parameters, but we’re also adding a ‘width’ parameter to specify the width of the mashup, and a ‘height’ parameter to specify the height.

[mashup id="2" title="My Second Mashup" width="500" height="300" /]

Remember that the ‘mashup’ shortcode is flexible, and you can add as many parameters as you need to create the perfect map for your WordPress site.

PHP Function Code

In case you have difficulties debugging what causing issues with [mashup] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('mashup', array(__CLASS__, 'shortcode_mashup'));

Shortcode PHP function:

function shortcode_mashup($atts='') {
		if (self::is_admin() || is_feed())
			return;

		$atts = self::scrub_atts($atts);
		return self::get_mashup($atts);
	}

Code file location:

mappress-google-maps-for-wordpress/mappress-google-maps-for-wordpress/mappress.php

Conclusion

Now that you’ve learned how to embed the MapPress Maps for WordPress Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *