Below, you’ll find a detailed guide on how to add the WP MapIt 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 WP MapIt Plugin shortcodes not to show or not to work correctly.
Before starting, here is an overview of the WP MapIt Plugin and the shortcodes it provides:
"WP MapIt is a powerful WordPress plugin that provides advanced mapping features. Tailor your website's navigation with this interactive tool for a more user-friendly experience."
- [wp_mapit]
- [wp_mapit_map]
WP MapIt [wp_mapit] Shortcode
The WP-Mapit shortcode is a powerful tool for generating maps on your WordPress site. It checks if a map exists, then generates it. This shortcode activates the WP-Mapit function, which generates a map if one is available. It’s a simple yet effective way to add interactive maps to your site.
Shortcode: [wp_mapit]
Examples and Usage
Basic example – A simple usage of the wp_mapit shortcode to display a map on your post or page.
[wp_mapit /]
Advanced examples
Adding parameters to the shortcode to customize the output of the map. In this example, we are specifying the zoom level and the map type.
[wp_mapit zoom="10" maptype="satellite" /]
In this next advanced example, we are specifying the latitude and longitude coordinates of the map center, along with the zoom level and map type.
[wp_mapit lat="40.7128" lng="-74.0060" zoom="10" maptype="satellite" /]
Remember, the wp_mapit shortcode will only display a map if a map has been set up and is available. If no map is available, the shortcode will not render anything.
PHP Function Code
In case you have difficulties debugging what causing issues with [wp_mapit]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'wp_mapit', __CLASS__ . '::wp_mapit' );
Shortcode PHP function:
function wp_mapit() {
if ( wp_mapit_map::has_map() ){
return wp_mapit_map::generate_map();
}
}
Code file location:
wp-mapit/wp-mapit/wp_mapit/classes/class.wp_mapit_shortcode.php
WP MapIt [wp_mapit_map] Shortcode
The WP MapIt plugin shortcode ‘wp_mapit_map’ generates a map based on the provided map ID. It verifies the existence of the map before generating it.
Shortcode: [wp_mapit_map]
Parameters
Here is a list of all possible wp_mapit_map shortcode parameters and attributes:
id
– It is the unique identifier of the map.
Examples and Usage
Basic example – To display a map using the WP Mapit plugin, you can use the shortcode and specify the id parameter. The id parameter refers to the ID of the map you want to display.
[wp_mapit_map id=1 /]
Advanced examples
While the WP Mapit plugin doesn’t support additional parameters in the shortcode, you can use other WordPress shortcodes or functions inside the WP Mapit shortcode to achieve more complex functionality. For example, you can use the do_shortcode function to execute another shortcode inside the WP Mapit shortcode. This can be useful if you want to display a map and a form (or any other element that can be inserted via a shortcode) at the same time.
Remember to replace the id in the shortcode with the actual ID of your map and the contact form.
Another advanced usage could be to use the WP Mapit shortcode inside a template file. This can be useful if you want to display the map in a specific position that cannot be achieved through the WordPress editor. To do this, you can use the do_shortcode function again, but this time inside a PHP file.
Again, remember to replace the id in the shortcode with the actual ID of your map.
PHP Function Code
In case you have difficulties debugging what causing issues with [wp_mapit_map]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'wp_mapit_map', __CLASS__ . '::wp_mapit_map' );
Shortcode PHP function:
function wp_mapit_map( $atts ) {
$mapId = isset( $atts['id'] ) ? intval( $atts['id'] ) : 0;
if( $mapId > 0 ) {
if ( wp_mapit_multipin_map::has_map( $mapId ) ) {
return wp_mapit_multipin_map::generate_map( $mapId );
}
}
}
Code file location:
wp-mapit/wp-mapit/wp_mapit/classes/class.wp_mapit_shortcode.php
Conclusion
Now that you’ve learned how to embed the WP MapIt 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.
Leave a Reply