Shortcodes
Maki Geo provides several shortcodes for both displaying location information and creating geo-targeted content.
Location Display Shortcodes
Display visitor location information anywhere in your content.
Country Flag
[mgeo_country_flag size="24px"]
Displays the visitor’s country flag. Optional size
parameter controls the flag size.
Country Name
[mgeo_country default="Unknown"]
Displays the visitor’s country name. Optional default
parameter sets fallback text.
Region/State
[mgeo_region default="Unknown"]
Shows the visitor’s region, state, or province. Optional default
parameter sets fallback text.
City
[mgeo_city default="Unknown"]
Shows the visitor’s city name. Optional default
parameter sets fallback text.
Continent
[mgeo_continent default="Unknown"]
Shows the visitor’s continent. Optional default
parameter sets fallback text.
Geo Content Shortcode
Create geo-targeted content using the [mgeo_content]
shortcode.
Basic Usage
[mgeo_content country="United States"] Content for US visitors[/mgeo_content]
Options
Attribute | Values | Explanation | Example value |
---|---|---|---|
continent | English name(s) of continent(s) | The continent(s) to match the rule on. | Africa,Europe |
country | English name(s) of country/countries. | The country/countries to match the rule on. | United States,Mexico |
region | English name(s) of the region(s). | The region(s) to match the rule on. For most countries, these are the names of states or provinces. | Alabama,Champagne |
city | English name(s) of the city/cities. | The city/cities to match the rule on. | New York,Mumbai |
ip | IP address(es). | The ip address(es) to match the rule on. | 127.0.0.1,103.21.244.0 |
match | ”all” (default) or “any”. | How the conditions should be matched. For “all” all conditions have to be met. For “any”, just one of the conditions has to be met | any |
action | ”show” (default) or “hide”. | “show” will show the block contents when the conditions are met and hide them when the conditions aren’t met. “hide”, whill hide the block contents when the conditions are met and show them when the conditions aren’t met. | 127.0.0.1,103.21.244.0 |
Multiple Conditions
[mgeo_content country="United Kingdom" city="London"] Content for visitors from the city London in the UK[/mgeo_content]
Note that the above example shows the content to visitors from the city London in the UK (so not London, Ontario, for example).
Multiple Values
[mgeo_content country="France,Germany,Italy" match="any"] Content for selected European countries[/mgeo_content]
Exclusion Rules
[mgeo_content country="!China"] Content for visitors outside China[/mgeo_content]
Hiding instead of showing
[mgeo_content action="hide" country="Mexico"] Content is hidden from visitors from Mexico, but shown to everyone else[/mgeo_content]
Nesting shortcodes for additional rules (advanced)
You can put shortcodes inside of shortcodes to create even more complex rules. For example:
[mgeo_content country="US,Canada" match="any"] [mgeo_content region="Quebec" action="hide"] Content for US visitors or Canadian visitors outside Quebec [/mgeo_content][/mgeo_content]
Best Practices
- Provide default values for location display shortcodes
- Keep targeting rules simple and logical
- Test your shortcodes with different locations