Unusually, I started working on the configuration of Quelbazar blog today. Program: a solution to customize some content of the blog based on the country of origin of the visitor. Specifically, I wanted to include country-specific ads. Because it doesn't help to offer Swiss ads to a french visitor, for example.
The method is quite simple, because others thought before us: there is a wordpress plugin that does it right: Custom Content By Country.
This plugin works through "shortcodes", so I let you go see the syntax in the documentation of the plugin. For the simple reason that I don't know how to insert a shortcode into the article unless it is interpreted…
The plugin works without other articles, but my goal was to use it in a widget. Article Using shortcodes everywhere gives us the solution: in the file functions.php (the one in wp-includes), add:
add_filter ('widget_text', 'shortcode_unautop');
add_filter ('widget_text', 'do_shortcode');
I did it at the beginning of the file inside the php code. Shortcodes are then interpreted in widgets, allowing me to offer the Swiss for the Swiss pub, and French advertising for others. There, on the right, the 2nd from the top pub.
[CBC country=”ch” show=”y”]And at the same time, it allows me to tell you that you are visiting this site from the Switzerland![/CBC]
[CBC country=”fr” show=”y”]And at the same time, it allows me to tell you that you are visiting this site from the France![/CBC]
[CBC country=”be” show=”y”]And at the same time, it allows me to tell you that you are visiting this site from the Belgium![/CBC]
[CBC country=”us” show=”y”]And at the same time, it allows me to tell you that you visit this site from the USA! Or via a RSS reader.[/CBC]
[CBC country=”ch,fr,be,us” show=”n”]And at the same time, it allows me to tell you that you are visiting this site from a country which is neither the Switzerland, the France nor the Belgium and or the USA. Or so that your IP is not geo-referenced.[/CBC]
In Switzerland, the transport network is becoming increasingly saturated: at peak times, roads in the catching areas of cities and towns suffer from congestion and trains are often crowded. Managing the parking space can help […]
On the blog of Quelbazar, it's quiet, lately. And when it's quiet around here, is that it is hectic in real life. But still some links: Over the web, the readings and news recommended by […]
I was telling you about 2 days ago from my first step in the path of the ridges of the Jura, my challenge 2017. And I told you that in view of the State of […]
Be the first to comment