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]
Amazon.com today announced that the minimum necessary to get free fast delivery in metropolitan France, Monaco, in Belgium and the Luxembourg purchase will increase since January 15, 2014: The minimum purchase password 15 euros to […]
Announced for August 22, Yallo is releasing a new subscription: Yallo Fat Plus. Normally at 78 frs per month, it is offered at 50% "for a limited time". But note that Yallo continually makes offers […]
The City of Lausanne obtains the Villeverte "money" label for its services in favour of green spaces and its sustainable approach to urban green zones. The "Villeverte Suisse" label is carried by the Swiss Union […]
Be the first to comment