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]
The blog of Quelbazar, absent from the Web for a few weeks, will return suddenly! Decommissioned in early April 2014 for technical reasons, it was supposed do not reappear. But him out wanted otherwise: 4000 […]
The French blogosphere is still in great shape in 2014: that was the point made by Quelbazar in early this year. But where hide speaking blogs? Inventory the French blogosphere? Yes, but how? And how […]
Over the web, the readings and news recommended by Quelbazar these last time: Google allows merchants to create a free website easily: Google is launching a new feature for local businesses. Institutions can create […]
Be the first to comment