Below, you’ll find a detailed guide on how to add the Geo Mashup 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 Geo Mashup Plugin shortcodes not to show or not to work correctly.
Before starting, here is an overview of the Geo Mashup Plugin and the shortcodes it provides:
"Geo Mashup is a powerful WordPress plugin that allows you to create customizable maps, enhancing your site with rich and interactive geographical content. Ideal for travel blogs, event sites, and more."
- [geo_mashup_show_on_map_link]
- [geo_mashup_show_on_map_link_url]
- [geo_mashup_category_name]
- [geo_mashup_category_legend]
- [geo_mashup_term_legend]
- [geo_mashup_list_located_posts]
- [geo_mashup_list_located_posts_by_area]
- [geo_mashup_tabbed_category_index]
- [geo_mashup_tabbed_term_index]
- [geo_mashup_visible_posts_list]
Geo Mashup [geo_mashup_show_on_map_link] Shortcode
The GeoMashup shortcode is a powerful tool that adds a ‘Show on map’ link to your posts. It uses the ‘show_on_map_link’ function to generate this link. The function takes various parameters such as ‘text’, ‘display’, ‘zoom’, and ‘show_icon’. These allow customization of the link’s display text, visibility, zoom level on the map, and the presence of an icon respectively.
Shortcode: [geo_mashup_show_on_map_link]
Parameters
Here is a list of all possible geo_mashup_show_on_map_link shortcode parameters and attributes:
text
– changes the default ‘Show on map’ text in the linkdisplay
– when set to true, the link is directly displayed on the pagezoom
– sets the zoom level of the map when the link is clickedshow_icon
– when true, a geotag icon is displayed next to the link text
Examples and Usage
Basic example – A simple usage of the geo_mashup_show_on_map_link shortcode to display a link with default settings.
[geo_mashup_show_on_map_link /]
Advanced examples
Displaying a custom text link to the map with a specific zoom level. The ‘text’ attribute changes the link text, and the ‘zoom’ attribute specifies the zoom level of the map when the link is clicked.
[geo_mashup_show_on_map_link text="View Location" zoom="10" /]
Showing a link without the geotag icon. The ‘show_icon’ attribute is set to false, so the geotag icon will not be displayed.
[geo_mashup_show_on_map_link show_icon="false" /]
Displaying a link and automatically printing it to the screen. The ‘display’ attribute is set to true, so the link will be automatically printed to the screen when the shortcode is processed.
[geo_mashup_show_on_map_link display="true" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [geo_mashup_show_on_map_link]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('geo_mashup_show_on_map_link', array( 'GeoMashup', 'show_on_map_link' ) );
Shortcode PHP function:
function show_on_map_link( $args = null ) {
$defaults = array( 'text' => __( 'Show on map', 'GeoMashup' ),
'display' => false,
'zoom' => '',
'show_icon' => true );
$options = wp_parse_args($args, $defaults);
$link = '';
$url = self::show_on_map_link_url( array_intersect_key( $options, array( 'zoom' => true ) ) );
if ( $url ) {
$icon = '';
if ($options['show_icon'] && strcmp( $options['show_icon'], 'false' ) !== 0) {
$icon = '<img src="'.GEO_MASHUP_URL_PATH.
'/images/geotag_16.png" alt="'.__('Geotag Icon','GeoMashup').'"/>';
}
$link = '<a class="gm-link" href="'.$url.'">'.
$icon.' '.$options['text'].'</a>';
if ($options['display']) {
echo $link;
}
}
return $link;
}
Code file location:
geo-mashup/geo-mashup/shortcodes.php
Geo Mashup [geo_mashup_show_on_map_link_url] Shortcode
The GeoMashup shortcode is a user-friendly tool to generate a specific URL that shows a location on a map. This shortcode fetches a location’s latitude and longitude, and plugs these coordinates into a URL. If the ‘auto_info_open’ option is set to ‘true’, the location’s object ID is also included in the URL. The generated URL leads to a map page that displays the specified location.
Shortcode: [geo_mashup_show_on_map_link_url]
Parameters
Here is a list of all possible geo_mashup_show_on_map_link_url shortcode parameters and attributes:
zoom
– Defines the initial zoom level of the mapcenter_lat
– Sets the latitude for the map center pointcenter_lng
– Sets the longitude for the map center pointopen_object_id
– Opens the info window of the specified object on the map
Examples and Usage
Basic example – Show a specific location on a map with the default zoom level.
[geo_mashup_show_on_map_link_url /]
Advanced examples
Display a specific location on a map with a custom zoom level. The zoom level is specified by the ‘zoom’ parameter. The higher the value, the closer the zoom.
[geo_mashup_show_on_map_link_url zoom=10 /]
Display a specific location on a map with a custom zoom level and automatically open the information window for the location. The ‘auto_info_open’ parameter is set to ‘true’ to open the information window.
[geo_mashup_show_on_map_link_url zoom=10 auto_info_open=true /]
Display a specific location on a map with a custom zoom level, automatically open the information window for the location, and center the map on specific latitude and longitude coordinates. The ‘center_lat’ and ‘center_lng’ parameters are used to specify the coordinates.
[geo_mashup_show_on_map_link_url zoom=10 auto_info_open=true center_lat=40.7128 center_lng=74.0060 /]
PHP Function Code
In case you have difficulties debugging what causing issues with [geo_mashup_show_on_map_link_url]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('geo_mashup_show_on_map_link_url', array( 'GeoMashup', 'show_on_map_link_url' ) );
Shortcode PHP function:
function show_on_map_link_url( $args = null ) {
global $geo_mashup_options;
$defaults = array( 'zoom' => '' );
$args = wp_parse_args( $args, $defaults );
$args = array_filter( $args );
$url = '';
$location = self::current_location_guess();
if ( $location ) {
$url = get_page_link($geo_mashup_options->get('overall', 'mashup_page'));
if ( !$url ) {
return '';
}
$args['center_lat'] = $location->lat;
$args['center_lng'] = $location->lng;
if ( $geo_mashup_options->get( 'global_map', 'auto_info_open' ) === 'true' ) {
$args['open_object_id'] = $location->object_id;
}
$url = htmlentities( add_query_arg( $args, $url ) );
}
return $url;
}
Code file location:
geo-mashup/geo-mashup/shortcodes.php
Geo Mashup [geo_mashup_category_name] Shortcode
The GeoMashup shortcode is a dynamic tool that fetches and displays the name of a specific category. This shortcode works by parsing the ‘map_cat’ option from the query string. If this option is set, it retrieves the corresponding category name using the WordPress function ‘get_cat_name’. This makes it a useful tool for displaying category-specific content on your WordPress site.
Shortcode: [geo_mashup_category_name]
Parameters
Here is a list of all possible geo_mashup_category_name shortcode parameters and attributes:
option_args
– Set of options passed to the function.QUERY_STRING
– The part of a URL which contains data parameters.map_cat
– The ID of the category to display on the map.
Examples and Usage
Basic example – A simple usage of the geo_mashup_category_name shortcode to fetch and display the name of a category using its ID.
[geo_mashup_category_name map_cat=3 /]
Advanced examples
Utilizing the geo_mashup_category_name shortcode to retrieve and display the name of a category by parsing a query string. This is useful when you want to fetch the category name dynamically based on user interaction or other factors.
[geo_mashup_category_name "map_cat=3&another_param=value" /]
Using the geo_mashup_category_name shortcode to display the category name within a text. This is useful when you want to include the category name within a sentence or paragraph.
Welcome to my blog! The category of this post is [geo_mashup_category_name map_cat=3 /].
PHP Function Code
In case you have difficulties debugging what causing issues with [geo_mashup_category_name]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('geo_mashup_category_name', array( 'GeoMashup', 'category_name' ) );
Shortcode PHP function:
function category_name($option_args = null) {
$category_name = '';
if (is_string($option_args)) {
$option_args = wp_parse_args($option_args);
}
if ( isset($_SERVER['QUERY_STRING']) && is_page() ) {
/** @noinspection AdditionOperationOnArraysInspection */
$option_args += self::explode_assoc('=','&',$_SERVER['QUERY_STRING']);
}
if (isset($option_args['map_cat'])) {
$category_name = get_cat_name($option_args['map_cat']);
}
return $category_name;
}
Code file location:
geo-mashup/geo-mashup/shortcodes.php
Geo Mashup [geo_mashup_category_legend] Shortcode
The GeoMashup plugin shortcode, ‘geo_mashup_category_legend’, generates a legend for map categories. It’s a useful feature to visually distinguish between different category markers. This shortcode calls the ‘category_legend’ function, returning a term legend based on the arguments passed. It simplifies the process of creating a category legend on your map.
Shortcode: [geo_mashup_category_legend]
Examples and Usage
Basic example – The following shortcode example will display a legend for all categories in your GeoMashup map.
[geo_mashup_category_legend /]
Advanced examples
Display a legend for specific categories by referencing their IDs. This will only show legends for the categories with ID 2 and 3.
[geo_mashup_category_legend ids="2,3" /]
Change the legend title by using the ‘title’ attribute. This will display a legend with the title “My Custom Title”.
[geo_mashup_category_legend title="My Custom Title" /]
Combine multiple attributes in one shortcode to customize the legend further. This will display a legend for categories with ID 2 and 3, with the title “My Custom Title”.
[geo_mashup_category_legend ids="2,3" title="My Custom Title" /]
Remember, the ‘ids’ attribute should be a comma-separated list of category IDs, and the ‘title’ attribute should be a string for the legend title.
PHP Function Code
In case you have difficulties debugging what causing issues with [geo_mashup_category_legend]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('geo_mashup_category_legend', array( 'GeoMashup', 'category_legend') );
Shortcode PHP function:
function category_legend($args = null) {
return self::term_legend( $args );
}
Code file location:
geo-mashup/geo-mashup/shortcodes.php
Geo Mashup [geo_mashup_term_legend] Shortcode
The GeoMashup plugin shortcode is a function that generates a term legend for a specified map. It parses arguments like ‘for_map’, ‘taxonomy’, ‘noninteractive’, ‘check_all’, ‘default_off’, ‘format’, and ‘titles’. The shortcode allows customization of the legend’s ID and classes based on the provided arguments. It returns a div element with the generated ID and classes.
Shortcode: [geo_mashup_term_legend]
Parameters
Here is a list of all possible geo_mashup_term_legend shortcode parameters and attributes:
for_map
– Defines map to apply legendtaxonomy
– Specifies taxonomy to be used in legendnoninteractive
– When set, disables user interactionscheck_all
– If set to false, all checkboxes start uncheckeddefault_off
– If set to false, all options are turned on by defaultformat
– Defines format of the legendtitles
– If set to false, hides title labels
Examples and Usage
Basic example – The shortcode below displays a simple geo mashup term legend for a specific map.
[geo_mashup_term_legend for_map="gm-map-1" /]
Advanced examples
Displaying a geo mashup term legend for a specific map and taxonomy, with the ‘noninteractive’ parameter set to true. The term legend will not respond to user interactions.
[geo_mashup_term_legend for_map="gm-map-1" taxonomy="category" noninteractive="true" /]
Displaying a geo mashup term legend with the ‘check_all’ parameter set to false. By default, all terms will not be checked.
[geo_mashup_term_legend for_map="gm-map-1" check_all="false" /]
Displaying a geo mashup term legend with the ‘format’ parameter set to ‘list’. The terms will be displayed in a list format.
[geo_mashup_term_legend for_map="gm-map-1" format="list" /]
Displaying a geo mashup term legend with the ‘titles’ parameter set to ‘false’. The term titles will not be displayed.
[geo_mashup_term_legend for_map="gm-map-1" titles="false" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [geo_mashup_term_legend]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('geo_mashup_term_legend', array( 'GeoMashup', 'term_legend') );
Shortcode PHP function:
function term_legend($args = null) {
$args = wp_parse_args($args);
$id = 'gm-map-1';
if ( !empty( $args['for_map'] ) ) {
$id = $args['for_map'];
}
if ( !empty( $args['taxonomy'] ) ) {
$id .= '-' . esc_attr ( $args['taxonomy'] );
}
$id .= '-legend';
$classes = array();
if ( !empty( $args['noninteractive'] ) && 'false' !== $args['noninteractive'] ) {
$classes[] = 'noninteractive';
}
if ( !empty( $args['check_all'] ) && 'true' !== $args['check_all'] ) {
$classes[] = 'check-all-off';
}
if ( !empty( $args['default_off'] ) && 'false' !== $args['default_off'] ) {
$classes[] = 'default-off';
}
if ( !empty( $args['format'] ) ) {
$classes[] = 'format-' . esc_attr( $args['format'] );
}
if ( isset( $args['titles'] ) ) {
if ( $args['titles'] && 'false' !== $args['titles'] ) {
$classes[] = 'titles-on';
} else {
$classes[] = 'titles-off';
}
}
return '<div id="' . $id . '" class="' . implode( ' ', $classes ) . '"></div>';
}
Code file location:
geo-mashup/geo-mashup/shortcodes.php
Geo Mashup [geo_mashup_list_located_posts] Shortcode
The GeoMashup shortcode is designed to list posts with geographic locations. It parses location data from posts and displays them in an unordered list. This shortcode retrieves the locations of posts and displays them as links. Each link leads to the respective post.
Shortcode: [geo_mashup_list_located_posts]
Examples and Usage
Basic example – Display a list of posts that have location data associated with them.
[geo_mashup_list_located_posts]
Advanced examples
Display a list of posts that have location data, but only for those posts that are within the ‘Travel’ category.
[geo_mashup_list_located_posts category_name='Travel']
Display a list of posts that have location data, but only for those posts that are tagged with ‘Europe’.
[geo_mashup_list_located_posts tag='Europe']
Display a list of posts that have location data, but only for those posts that are from the ‘Photography’ post type.
[geo_mashup_list_located_posts post_type='photography']
These examples show how you can use the ‘geo_mashup_list_located_posts’ shortcode with different parameters to filter and display posts based on various criteria. The parameters used in these examples are ‘category_name’, ‘tag’, and ‘post_type’.
PHP Function Code
In case you have difficulties debugging what causing issues with [geo_mashup_list_located_posts]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('geo_mashup_list_located_posts', array( 'GeoMashup', 'list_located_posts' ) );
Shortcode PHP function:
function list_located_posts( $option_args = null ) {
$option_args = wp_parse_args( $option_args );
$option_args['object_name'] = 'post';
$list_html = '<ul class="gm-index-posts">';
$locs = GeoMashupDB::get_object_locations( $option_args );
if ($locs) {
foreach ($locs as $loc) {
$list_html .= '<li><a href="'.get_permalink($loc->object_id).'">'.
$loc->label."</a></li>\n";
}
}
$list_html .= '</ul>';
return $list_html;
}
Code file location:
geo-mashup/geo-mashup/shortcodes.php
Geo Mashup [geo_mashup_list_located_posts_by_area] Shortcode
The GeoMashup shortcode is a powerful tool for listing posts by geographical area. It generates a list of posts, grouped by country and state, with links to each post. This shortcode fetches distinct country codes associated with posts, and for each country, it retrieves posts grouped by administrative codes (states). It creates a hierarchical list with country and state headings, followed by the linked post titles. If the ‘include_address’ argument is set to true, the post’s address is also included.
Shortcode: [geo_mashup_list_located_posts_by_area]
Examples and Usage
Basic example – Utilizes the shortcode to list out all posts that have location data associated with them. This is a great way to quickly create a directory of all geolocated posts on your site.
[geo_mashup_list_located_posts_by_area /]
Advanced example – This example includes an additional parameter ‘include_address’. When set to ‘true’, it will include the address of each post’s location in the listing. This can be useful when you want to provide more detailed location information to your users.
[geo_mashup_list_located_posts_by_area include_address=true /]
Another advanced usage of this shortcode could be to limit the listing to posts from a specific country or state. In the example below, we’re using the ‘country_code’ and ‘admin_code’ (state) parameters to limit the listing to posts located in the state of California, USA (‘US’ and ‘CA’ respectively).
[geo_mashup_list_located_posts_by_area country_code=US admin_code=CA /]
PHP Function Code
In case you have difficulties debugging what causing issues with [geo_mashup_list_located_posts_by_area]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('geo_mashup_list_located_posts_by_area', array( 'GeoMashup', 'list_located_posts_by_area' ) );
Shortcode PHP function:
function list_located_posts_by_area( $args ) {
static $instance_count = 1;
$args = wp_parse_args( $args );
$id_suffix = ( $instance_count > 1 ) ? '-' . $instance_count : '';
$list_html = '<div id="gm-area-list' . $id_suffix . '" class="gm-area-list">';
$countries = GeoMashupDB::get_distinct_located_values( 'country_code', array( 'object_name' => 'post' ) );
$country_count = count( $countries );
$country_heading = '';
foreach ( $countries as $country ) {
if ( $country_count > 1 ) {
$country_name = GeoMashupDB::get_administrative_name( $country->country_code );
$country_name = $country_name ? $country_name : $country->country_code;
$country_heading = '<h3 id="' . $country->country_code . $id_suffix . '">' . $country_name . '</h3>';
}
$states = GeoMashupDB::get_distinct_located_values(
'admin_code',
array( 'country_code' => $country->country_code, 'object_name' => 'post' )
);
if ( empty( $states ) ) {
$states = array( (object) array( 'admin_code' => null ) );
}
foreach ($states as $state ) {
$location_query = array(
'object_name' => 'post',
'country_code' => $country->country_code,
'admin_code' => $state->admin_code,
'sort' => 'post_title'
);
$post_locations = GeoMashupDB::get_object_locations( $location_query );
if ( count( $post_locations ) > 0 ) {
if ( ! empty( $country_heading ) ) {
$list_html .= $country_heading;
$country_heading = '';
}
if ( null !== $states[0]->admin_code ) {
$state_name = GeoMashupDB::get_administrative_name( $country->country_code, $state->admin_code );
$state_name = $state_name ? $state_name : $state->admin_code;
$list_html .= '<h4 id="' . $country->country_code . '-' . $state->admin_code . $id_suffix . '">' . $state_name . '</h4>';
}
$list_html .= '<ul class="gm-index-posts">';
foreach ( $post_locations as $post_location ) {
$list_html .= '<li><a href="' .
get_permalink( $post_location->object_id ) .
'">' .
$post_location->label .
'</a>';
if ( isset( $args['include_address'] ) && $args['include_address'] === 'true' ) {
$list_html .= '<p>' . $post_location->address . '</p>';
}
$list_html .= '</li>';
}
$list_html .= '</ul>';
}
}
}
$list_html .= '</div>';
return $list_html;
}
Code file location:
geo-mashup/geo-mashup/shortcodes.php
Geo Mashup [geo_mashup_tabbed_category_index] Shortcode
The GeoMashup shortcode is a powerful tool that generates a tabbed index of categories. This allows you to organize your posts by category in a tidy, user-friendly format. This shortcode calls the ‘tabbed_category_index’ function, which in turn invokes the ‘tabbed_term_index’ function. The result is a streamlined, category-based index for your content.
Shortcode: [geo_mashup_tabbed_category_index]
Examples and Usage
Basic example – The GeoMashup plugin shortcode is used to display the tabbed category index.
[geo_mashup_tabbed_category_index]
Advanced examples
Using the shortcode with the ‘count’ parameter set to ‘true’ will display the number of posts in each category in the tabbed index.
[geo_mashup_tabbed_category_index count=true]
Another advanced usage of the shortcode is to display the tabbed category index with a specific category excluded. Here, the ‘exclude’ parameter is set to the ID of the category to be excluded.
[geo_mashup_tabbed_category_index exclude=3]
You can also use the shortcode to display the tabbed category index with only specific categories included. Here, the ‘include’ parameter is set to the IDs of the categories to be included.
[geo_mashup_tabbed_category_index include="1,2,3"]
Finally, you can use the shortcode to display the tabbed category index with categories ordered by name in ascending order. Here, the ‘orderby’ parameter is set to ‘name’ and the ‘order’ parameter is set to ‘ASC’.
[geo_mashup_tabbed_category_index orderby=name order=ASC]
PHP Function Code
In case you have difficulties debugging what causing issues with [geo_mashup_tabbed_category_index]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('geo_mashup_tabbed_category_index', array( 'GeoMashup', 'tabbed_category_index' ) );
Shortcode PHP function:
function tabbed_category_index( $args ) {
return self::tabbed_term_index( $args );
}
Code file location:
geo-mashup/geo-mashup/shortcodes.php
Geo Mashup [geo_mashup_tabbed_term_index] Shortcode
The GeoMashup shortcode ‘geo_mashup_tabbed_term_index’ creates a tabbed index for terms in a specific taxonomy. It allows customization of the map ID, taxonomy, tab markers, start term, group size, and auto-selection feature. .
Shortcode: [geo_mashup_tabbed_term_index]
Parameters
Here is a list of all possible geo_mashup_tabbed_term_index shortcode parameters and attributes:
for_map
– Specifies the map to which the term index belongstaxonomy
– Defines the taxonomy to be used in the term indexshow_inactive_tab_markers
– Controls whether to show markers on inactive tabsstart_tab_term
– Sets the term to be selected when the term index loadstab_index_group_size
– Determines the number of terms per tab in the term indexdisable_tab_auto_select
– Prevents automatic tab selection based on content
Examples and Usage
Basic example – A straightforward usage of the ‘geo_mashup_tabbed_term_index’ shortcode. This example does not include any additional parameters, thus it will use the default settings defined in the function.
[geo_mashup_tabbed_term_index]
Advanced examples
1. In this example, the shortcode is used with a specific map id and taxonomy. The ‘for_map’ parameter is used to specify the map id, and the ‘taxonomy’ parameter is used to specify the taxonomy.
[geo_mashup_tabbed_term_index for_map="gm-map-2" taxonomy="category"]
2. This example demonstrates the use of the ‘show_inactive_tab_markers’ and ‘start_tab_term’ parameters. If ‘show_inactive_tab_markers’ is set to true, markers for inactive tabs will be displayed. The ‘start_tab_term’ parameter is used to specify the term that should be active when the page loads.
[geo_mashup_tabbed_term_index show_inactive_tab_markers="true" start_tab_term="5"]
3. In this final advanced example, the shortcode is used with the ‘tab_index_group_size’ and ‘disable_tab_auto_select’ parameters. The ‘tab_index_group_size’ parameter is used to specify the number of terms per tab, and the ‘disable_tab_auto_select’ parameter is used to disable automatic selection of the first tab when the page loads.
[geo_mashup_tabbed_term_index tab_index_group_size="10" disable_tab_auto_select="true"]
PHP Function Code
In case you have difficulties debugging what causing issues with [geo_mashup_tabbed_term_index]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('geo_mashup_tabbed_term_index', array( 'GeoMashup', 'tabbed_term_index' ) );
Shortcode PHP function:
function tabbed_term_index( $args ) {
$args = wp_parse_args($args);
$id = 'gm-map-1';
if ( !empty( $args['for_map'] ) ) {
$id = $args['for_map'];
}
if ( !empty( $args['taxonomy'] ) ) {
$id .= '-' . esc_attr ( $args['taxonomy'] );
}
$id .= '-tabbed-index';
$classes = array();
if ( !empty( $args['show_inactive_tab_markers'] ) &&
'false' !== $args['show_inactive_tab_markers']
) {
$classes[] = 'show-inactive-tab-markers';
}
if ( !empty( $args['start_tab_term'] ) ) {
$classes[] = 'start-tab-term-' . absint( $args['start_tab_term'] );
}
if ( !empty( $args['tab_index_group_size'] ) ) {
$classes[] = 'tab-index-group-size-' . absint( $args['tab_index_group_size'] );
}
if ( !empty( $args['disable_tab_auto_select'] ) && 'false' !== $args['disable_tab_auto_select'] ) {
$classes[] = 'disable-tab-auto-select';
}
return '<div id="' . $id . '" class="' . implode( ' ', $classes ) . '"></div>';
}
Code file location:
geo-mashup/geo-mashup/shortcodes.php
Geo Mashup [geo_mashup_visible_posts_list] Shortcode
The GeoMashup shortcode is a powerful tool that creates a list of posts visible on a specific map. It accepts arguments for map ID and heading text. This shortcode fetches posts associated with a specific map (default is ‘gm-map-1’). If a ‘heading_text’ argument is provided, it generates a header with the specified text. The returned HTML string includes a div element containing the list of visible posts.
Shortcode: [geo_mashup_visible_posts_list]
Parameters
Here is a list of all possible geo_mashup_visible_posts_list shortcode parameters and attributes:
for_map
– specifies the map to display the visible posts list on.heading_text
– sets the text for the heading of the visible posts list.heading_tags
– defines the HTML tags for the heading text.
Examples and Usage
Basic example – Show a visible posts list for a specific map.
[geo_mashup_visible_posts_list for_map="gm-map-1" /]
Advanced examples
Display a visible posts list with a custom heading text.
[geo_mashup_visible_posts_list for_map="gm-map-1" heading_text="My Custom Heading" /]
Display a visible posts list with custom heading tags and text.
[geo_mashup_visible_posts_list for_map="gm-map-1" heading_tags="" heading_text="My Custom Heading" /]
Display a visible posts list with a custom div id for the heading.
[geo_mashup_visible_posts_list for_map="gm-map-1" heading_div_id="custom-div-id" heading_text="My Custom Heading" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [geo_mashup_visible_posts_list]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode('geo_mashup_visible_posts_list', array( 'GeoMashup', 'visible_posts_list' ) );
Shortcode PHP function:
function visible_posts_list($args = null) {
$args = wp_parse_args($args);
$list_html = '';
$for_map = 'gm-map-1';
if ( !empty( $args['for_map'] ) ) {
$for_map = $args['for_map'];
}
if ( !empty( $args['heading_text'] ) ) {
$heading_div = '<div id="' . $for_map . '-visible-list-header" style="display:none;">';
$heading_tags = '<h2>';
if ( !empty( $args['heading_tags'] ) ) {
$heading_tags = $args['heading_tags'];
}
$list_html .= balanceTags( $heading_div . $heading_tags . $args['heading_text'], true );
}
$list_html .= '<div id="' . $for_map . '-visible-list"></div>';
return $list_html;
}
Code file location:
geo-mashup/geo-mashup/shortcodes.php
Conclusion
Now that you’ve learned how to embed the Geo Mashup 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