Country Filter WordPress plugin


Country Filter plugins allows you to control the visibility of WordPress elements depending on the users country of origin. You can hide or show certain elements of a page or some sections of a post from users browsing from a particular country. For example you could have a ‘donate’ button that displays only if the user is browsing from France, or display one ‘Buy Now’ button for a particular country and another for other countries. Maybe you want to display a video only for users in the US or Australia.

Developers and designers could use the plugin to load different stylesheets based on the users country. Services like uses techniques such as this to constrain viewership to a particular country.

Supported WordPress versions

WordPress 2.5 and above. Tested upto version 4.0

Purchase Plugin

Buy Now

The download link will be emailed to you immediately on payment. Also, any future updates will be free for all buyers and will be emailed to you as and when available.

Installing the Country Filter plugin

Installation instructions are provided in the download.

>> Usage

Country Filter plugin works mainly in two ways – via a short code, and by directly adding some PHP code.

Short codes

The easiest method is to use the short-codes. This will allow you to show/hide content in posts by using the ‘country-filter‘ shortcode. For example if you want to show a certain part of your posts/page only to users who are browsing from ‘United States’ or from ‘India’ than you can use the following code. The code used are the ISO 3166-1 alpha-2 2 digit codes.

[country-filter code="us, in"  display="1"] 
Hello World! 

Setting the above shortcode in a post/page will display the string ‘Hello World!’ only for the users in US and India. People in other countries will not be able to see the string. On the other hand, setting the display attribute to ‘0’ will hide the content for users in US and India but will display the string to people from other countries as given in the following code. Note that the content between shortcodes can be anything you like.

[country-filter code="us, in"  display="0"] 
Hello World! 

Suppose you want to display a ‘Buy Now’ button in a post, maybe you are selling a product and want to add different prices – one for the users in the US and another for all other countries. You can then use the short codes as below. So now, if a user is browsing from the US the first shortcode rule applies and the text ‘Buy Now for only $45′ is displayed, on the other hand, for users from other countries the second rule applies and the text ‘Buy Now for only $32′ is displayed. As said earlier the second shortcode hides the text for the users form the US but displays for all others.

[country-filter code="us"  display="1"] 
Buy Now for only $45
[country-filter code="us"  display="0"] 
Buy Now for only $32

The short code takes two attributes, both of which are mandatory.

code : A comma separated list of 2 digit ISO 3166-1 alpha-2 country codes.
display : Set to ‘1’ if you want to display or ‘0’ if you want to hide the content. If set to ‘0’ the content will be hidden for the given countries but displayed for others.

Nesting Short codes

You can nest your other plugin short codes in between the ‘country-filter’ short code to control the visibility of the other plugin data. For example, the following code nests the WordPress ‘gallery’ shortcode, which will now only be displayed if the user is browsing from the US or India.

[country-filter code="us, in"  display="1"] 

Maybe you have a form plugin which provides a ‘[form]’ shortcode and you want to display the form only for users NOT from the US. The following gives an example for that particular scenario.

[country-filter code="us"  display="0"] 

Another use case frequently needed by users – to show / hide PayPal buttons for different countries. For example the following will show the PayPal ‘Buy Now’ button for US users only.:

[country-filter code="us" display="1"]
<form action="" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="">
<input type="hidden" name="lc" value="US">
<input type="hidden" name="item_name" value="Design e-book">
<input type="hidden" name="amount" value="12.00">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="0">
<input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest">
<input type="image" src="" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="" width="1" height="1">

Filtering other content

You can also filter content other than posts with the isCountryInFilter function. Note that for this you will need to make changes to sections of the theme files. For example if you would like to display some content – like a button, a widget or some section of a web page, that should only be visible for people browsing from US, UK or Australia than you can do it as follows.

<?php if (function_exists('isCountryInFilter')) { ?>
<?php if(isCountryInFilter(array("us", "gb", "au"))) { ?> 
// The content here is displayed only for users 
// browsing from US, UK or Australia.
<?php } } ?>

You can also add a else section.

<?php if (function_exists('isCountryInFilter')) { ?>
<?php if(isCountryInFilter(array("us", "gb", "au"))) { ?> 
// The content here is displayed only for users 
// browsing from US, UK or Australia.
<?php } else { ?>
// People from other countries will see the content
// given here but not the above.
<?php } } ?>

This is a powerful way to control content on your WordPress site. You can control almost any type of content with this method. You can hide/display entire sections of WordPress depending on the users country.

Note that the isCountryInFilter function takes an array of country codes and returns true if the country code of the user browsing the site is in the array. Note that this function is especially useful for developers, as they can include custom code and other files depending on the users country.

Another function added in version 1.5 is showCountryContentInPage. This function is just like the short code version above, but can be used to manipulate content other than posts. This takes an extra ‘display’ parameter after the countries array. If set to ‘1’ than the content will be only displayed for the given countries. If set to ‘0’ than the content will be hidden for the given countries but displayed for others.

<?php if (function_exists('showCountryContentInPage')) { ?>
<?php if(showCountryContentInPage(array("us", "gb", "au"), 1)) { ?> 
// The content here is displayed only for users
// browsing from US, UK or Australia.
<?php } } ?>

Take another example – we want to display different banners depending on if the user is from the US, the Netherlands and a third banner for all other users.

<?php if (function_exists('showCountryContentInPage')) { ?>
<?php if(showCountryContentInPage(array("us"),1)) { ?> 
// The banner here is displayed only for users browsing from US.
<?php } elseif(showCountryContentInPage(array("nl"),1))  { ?>
// The banner here is displayed only for users browsing from Netherlands.
<?php } else  { ?>
// People from other countries will see the content
// given here but not the US, or Netherlands (nl).
<?php } } ?>

Another example – you want to display a certain banner in the sidebar (or anywhere else) which will be visible to all the users from all countries except the ‘US'; in short, we want to hide the banner for users from the ‘US’ only.

<?php if (function_exists('showCountryContentInPage')) { ?>
<?php if(showCountryContentInPage(array("us"),0)) { ?> 
   <img src="images/some_banner.jpg" />
<?php } } ?>


The plugin dashboard also displays the total number of times any content has been filtered by geographic areas. Note that data logging is disabled by default so you will need to enable it from the plugins admin section to be able to see the data on the map.

You can also export the generated data as a CSV file, which you can further analyze in a spreadsheet.


Plugin fails to activate
If the plugin fails to activate and displays and error, check the table names in the database, they are case sensitive. They should be ‘ip2nation’ and ‘ip2nationCountries’ if you are using the ip2nation Version of the plugin. This will work on Windows but will fail on Linux systems as the files there are case sensitive.

Plugin gives inaccurate results
This can happen if your PC is behind a firewall, proxy or a VPN. This programs tend to hide your original IP address, which can result in incorrect results. This is something the plugin, or for that matter any other plugin, cannot do anything about.


Will the plugin work with mobile devices and sites.
As long as your mobile device provides a correct ip address the plugin will work without any problem. Go to a site such as or to check the ip address of your mobile.

Some of the sites using the plugin

Purchase Plugin

Buy Now


# Version 1.01
* FIXED: Problem between spaces in country codes
# Version 1.1
* ADDED: Support for nested shortcodes
# Version 1.5
* ADDED: New function and changed some logic.
Thanks to Matt of NuFlux Media Inc for providing excellent feedback.
# Version 2.0
* ADDED: Users visualization by country.

176 Responses


WordPress Plugin Releases for 07/08 | Weblog Tools Collection

July 7th, 2009 at 1:08 pm

[…] Country Filter […]


EasySeo | WordPress Plugin Releases for 07/08 | SEO2Blog

July 7th, 2009 at 5:41 pm

[…] Country Filter […]


New Wordpress Plugins Release 07/08/2009

July 7th, 2009 at 6:08 pm

[…] Country Filter […]


WordPress Plugin Releases for 07/08 | The Cliffmaster

July 8th, 2009 at 6:39 am

[…] Country Filter […]


Tim Marchant

July 12th, 2009 at 2:14 am

Thanks for this. It would be worth adding a couple of lines above telling people how to do:

} else {




July 17th, 2009 at 11:55 am

Hey Sameer,

Thanks for the plugin! It’s exactly what I have been looking for.

But unfortunately, it’s not working for me. I have the plugin activated, and the database installed (I see them in phpmyadmin).

I tried the following code,

[country-filter code=”us, in, uk” display=”1″]
Hello World!


[country-filter code=”us, in, uk” display=”0″]
Hello World!

But I see nothing at all in my post. Any ideas?

Many thanks,



July 17th, 2009 at 12:01 pm

Damn, the php code in my sidebar didn’t work either :/

I’m quite sure I set everything up okay.

Thanks for your help, it should be a great plugin!


WordPress Plugin Releases for 07/08 « Web And Graphics Design Tutorials

July 28th, 2009 at 8:56 am

[…] Country Filter […]


New Useful WordPress Tricks & Hacks | ART HACKER

August 13th, 2009 at 10:48 pm

[…] Filter content by country […]


30+ Tips&Plugin per Wordpress | GeekTwice

August 20th, 2009 at 1:05 am

[…] Filter Content By Country […]


Unlimited New Useful Wordpress Tips,Tricks & Hacks - Themeflash : One Stop For All Your Web Resources

August 23rd, 2009 at 11:41 pm

[…] Filter content by country […]


30+ New Useful WordPress Tricks & Hacks | MEN blog . net

September 4th, 2009 at 2:26 am

[…] Filter content by country […]


Sergio Hernandez

September 5th, 2009 at 7:42 am

Thanks, Great plugin…! The best..


30+ New Useful WordPress Tricks & Hacks | My Tech way

September 14th, 2009 at 6:51 am

[…] Filter content by country […]


John Thornley

October 1st, 2009 at 4:38 am

If you are from the UK (like me) then just be aware that the example is incorrect. You need to use “gb” not “uk” as is stated in the example.

Just trying this plugin out and it wasn’t working… when I investigated then this was the problem.

Apart from that, it seems like a brilliant plugin. Thank you very much for all your hard work in making it.




sakthi Ganesh

October 2nd, 2009 at 9:56 am

I really appreciate for these kind of exceptional plug-in . Hats off for the good work . Looking more in future


George Rakkos

October 13th, 2009 at 4:53 am

I second this:

“Thanks for this. It would be worth adding a couple of lines above telling people how to do:
} else {“


George Rakkos

October 13th, 2009 at 5:01 am

small problem i updated to 1.5 and it does not work as before



November 12th, 2009 at 7:47 am

This plugin saved my life, I really cant thank you enough!

We originally quoted for a site to be duplicated 7 times for 7 different country prices. Now all we need to do is 1 wordpress build and utilize this script to enable the site to hide/show the different prices based on ip.



Sakthi Ganesh

November 23rd, 2009 at 7:52 am

I have found some issues with my setup ( may be with this plugin)

I have blacklisted the various offensive words using the filter textbox . one of the word is “ass” .I have included the conclusion that ,the plugin may find and replace the ” Three letter world” combination of “a”,”S”,”S” that forms the word “ass”.

But what it happened is
It blocked the words that start with particular three letter word .For example it blocked and replaced theword

“Assets” with ” ***ets ” which one i didn’t expected

For example the line is become

To protect the digital ***ets( which one is gone meaningless )

Is that any solution for that ?


November 23rd, 2009 at 10:12 pm

The plugin doesn’t work as a language filter, but as a content filter for country codes.



November 24th, 2009 at 12:13 am

It seems that this plugin doesn’t work inside a widget :( I want to create a text box widget and insert country filter code there (to show some banners to specific country) but it just shows the country filter code there. Anyone else has the same issue?


Sakthi Ganesh

November 24th, 2009 at 1:12 am


I am very sorry for mis posted comment numbered 20.

The comment numbered 20 is mis posted and these bug report should be made to the plugin

Sammer your plugin is a exceptional plugin i will write a review on my blog and i will let you know!

I am sorry sameer and the fellow readers for this .



December 1st, 2009 at 1:48 pm

You know what would be really cool? If it was possible to show or hide an entire post, not just its contents.

Maybe it can be done through tags or catagories?


Simone Carletti

December 22nd, 2009 at 10:05 pm

there’s a small bug when the user is connecting through a proxy.

You should change

$ip_address = $_SERVER[“HTTP_X_FORWARDED_FOR”])));


$ip_address = trim(end(split(“,”, $_SERVER[“HTTP_X_FORWARDED_FOR”])));

Proxies usually appends the full ip chain in the header, values are separated by commas. The last element is the public IP.
Example # public IP, # proxy + public IP,, # lan + proxy + public IP



December 28th, 2009 at 7:55 pm

Huge Thanks!

If I am able to implement this the way that I am planning (geo-specific advertising) it should bring me some extra income and if it does then I will definitely float some of that your way!

By the way, the final example above is using the wrong function. It should be the “showCountryContentInPage” in the example, correct?


December 28th, 2009 at 10:26 pm

Thanks for pointing out the error James.



December 29th, 2009 at 10:33 pm

I am very curious about Simone Carletti’s suggestion above regarding some additional parsing to handle proxied IP addresses.

Have you tested this Simone?

Sameer, what do you think?

I can tell you that I tried using my company’s VPN in a different country and the filter responded to the country of my VPN connection (not my true location), just as most web site’s do. Would Simone’s suggestion allow this code to see my originating IP address when using a VPN connection?


December 29th, 2009 at 11:52 pm

Hello James! I’ve not yet tested the proxy modification at my end, will do in a couple of days; meanwhile you can try it at your end and let me know the results.



January 5th, 2010 at 12:54 pm

Is it possible to use this plugin in e107 CMS ???

Great plugin and I want to integrate it in e107 system…

Thank You for any kind of help….


January 5th, 2010 at 9:00 pm

You cannot use the plugin in e107.



March 12th, 2010 at 10:21 am

Hi sameer

great plugin to filter content. I was searching this kind of filtering plugin for doing some css tricks in my website.So I can add some custom css elements or change look of some divs based on visitors country. any idea to do this ?
I am a designer and frontend developer for static website to cms. I also provide design services. I live in pune. Someday we can meet up for coffee.

bhetu ya ekda ! :)


March 12th, 2010 at 10:38 pm

You can try this in your templates header.php :



April 8th, 2010 at 1:34 am


Great plugin! I’ve been searching for something like this. I want to test this out with different ips via proxies. Did you get a chance to make modifications to the plugin to accommodate proxies as suggested in above post?


April 8th, 2010 at 8:11 pm


I’ve not yet accommodated for proxies yet!



April 8th, 2010 at 10:17 pm

Thanks Sameer.

Is there any way to test the dynamic content that shows up based on country? I’m sure the plugin works great, but how would I test the country-specific message or in my case a flash file without actually seeing it?

Can anyone else comment on how they were able to test their country-specific content?


April 8th, 2010 at 11:14 pm


You need to run your site through some proxy servers. Try this one. but with caution:

It lets you select the Country where the proxy is located. This way you can check if your data is correctly showing up for that particular country. Also check this link addressing your type of query:



May 7th, 2010 at 12:51 pm

Hi Sameer,

Thanks for creating this plugin, it should be really useful for creating targeted advertising content.

I am experiencing a slight inconsistency where my content, which is targeted at the UK, appears on my home machine but not on my work machine. I’ve checked both IP addresses here: and they are both geo-located as uk. Do you have any ideas of why the content does not appear?


May 9th, 2010 at 9:55 pm

Check if the ip is behind a firewall.



May 10th, 2010 at 1:06 am

Hi Sameer,

Seems to be working ok now. Must have been a problem at my end.

All the best,




June 19th, 2010 at 5:39 am

Hi Samir,

great plugin, thank you. It worked perfect for me until today (when I installed WP 3.0).

The thing that I want to appear only for some countries is a table built with Wp-Table Reloaded plugin. When I installed WP 3.0 the table stopped appearing at all for any country.
Can you give me a clue what to do.



June 19th, 2010 at 6:51 am

The plugin requires the ip2nation database, if your WordPress installation is new check if the database is present.

table 1 : ip2nation
table 2 : ip2nationcountries



June 19th, 2010 at 8:44 am

Hi Sameer,

please disregard my previous comment. I tested further the problem is only with Mozilla browser. I guess that there is something wrong at my end.

Thanks again for the great plugin.



August 25th, 2011 at 5:48 am

Hi Sameer

I need filter content by country, and this plugin is perfect. But I need add a button o category filter, for make more simple use… I can make this?



August 25th, 2011 at 9:51 am

My friend: this plugin hide part of post, but I need hide or show entire posts…


August 25th, 2011 at 8:18 pm

Italo, the plugin currently does not support hiding entire posts and at present have no plans on doing the same. But when I update the plugin I’ll surely let you know.



September 6th, 2011 at 3:34 am

What about “else”
It would be better if we can use the tag ‘else”


September 6th, 2011 at 4:57 am

Of course you are free to use the ‘else’ keyword when the ‘if’ condition is not satisfied.



September 8th, 2011 at 3:21 am

Got this error:

The plugin requires the ‘ip2nation’ and ‘ip2nationcountries’ database to be installed.
You can download the same from

But i imported the tables in my database. It seems like the plugin can’t find them.

Is there a fix for this?




September 9th, 2011 at 8:50 pm

I have already installed Country Filter Free version and it seems not working now.


September 9th, 2011 at 10:44 pm

The free version has been removed. The files posted at wordpress repository are blank, as it does not allow deletion of existing files.



September 14th, 2011 at 4:53 am

Just so I have the understanding of GPL licensing correct.

I am running 1.5.0 of the plugin as downloaded from

Is this permitted? If I understand GPL License agreements, there no reason I shouldn’t be allowed to use it with all rights reserved?


September 14th, 2011 at 5:12 am

yes, you can use it.



October 4th, 2011 at 1:15 am

Thinking of buying this plugin.

Will it work for mobile sites where I want to show different things depending for different countries?


October 4th, 2011 at 6:57 am

Yes it works with mobile devices. As long as your mobile provides a correct ip address, the plugin will work correctly.



October 4th, 2011 at 2:39 pm

Hi again,

Just purchased your plugin. Installed successfully but when I come to activate, I get this error message “The plugin does not have a valid header.”.


I have also downloaded the ip2nation files mentioned above. No idea where to store it, so I just kept the ip2nation zip file in the same folder as the Country-Filter zip file



October 4th, 2011 at 2:49 pm

Please ignore my last question. I know what I’ve done wrong.



November 6th, 2011 at 2:00 pm

Is there a list of country codes to use with this plugin? Could not find them at ip2nation.

Also wondering how to install the ip2nation files before ordering .. thanks



November 15th, 2011 at 8:15 am

Hi, I’m using Ad Injection wordpress plugin and saw that the author recommended your plugin if I we want to filter ads.

I’d like to buy your plugin but I’m not sure if this will work with WP Super Cache as well. Will I still have dynamic ad contents and at the same time filter them by your plugin?

Looking forward to your response! Thanks!


November 15th, 2011 at 9:25 am

The plugin currently does not support super cache.


Donald Laurel

December 22nd, 2011 at 7:19 am

Is their a way to show/hide the website from specific country? If there is, what is the code and where to put using wordpress version 3.2.1.

all I can see here is show/hide some elements in pages and posts.

Hoping for your quickest reply.

Thank you


December 22nd, 2011 at 10:15 am

You cannot use the plugin to hide whole sites. There is another plugin, ‘Country Redirect’ that allows you to redirect particular pages or the home page to other pages or urls.


Donald Laurel

December 22nd, 2011 at 11:03 pm

Hi Sameer,

I see. Thank you for the quick responds.




December 23rd, 2011 at 10:27 am

Works great with WordPress 3.3 ! Thanks a lot!



December 23rd, 2011 at 12:23 pm

Not sure what’s wrong, but I’ve set different ad for UK readers and US readers, but somehow, the plugin keeps displaying the US ads even though I’ve used UK proxy to view my web. I’m using maxmind version.

Please help Sameer


December 23rd, 2011 at 8:19 pm

Hello Carrie!

There are three reasons.

1. Check that no cache plugin like ‘wp-super cache’ is installed.

2. Go to ‘’ and get the ip of your proxy server. Then go to ‘’ and at the left bottom corner on the page enter the ip address. See what location it is returning.

3. Update your ‘GeoIP.dat’ file in the plugin directory with the latest version of the file from:

Tell me how it goes.



January 4th, 2012 at 2:26 am

Okay so i’m using GeoIP Lite and getting some complaints that the content doesn’t show.. everything works fine but some IP adresses are obviously not in the GeoIP database.. i was wondering if ip2nation is maybe better then GeoIP ?

Somebody who tried both and know what the best one is?



January 4th, 2012 at 2:36 am

Hello Youssef.

Did you update the GeoIP lite database from their website :

Also if some ips are behind a firewall or a proxy, then they will not work correctly. Their is no solution for that.



February 9th, 2012 at 11:40 am

Have you updated this plugin to work with a cache plugin as site speed seems more important in 2012


February 9th, 2012 at 9:40 pm

I’ve not yet found a reliable solution for that. To understand the reason you need to know how most WordPress cache plugins works:

Whenever a query is made to a post/page, a cache plugin process the php page and saves the snapshot as a static HTML file. So the next time whenever a request is made to the same page, the cache system returns the static page rather then executing the complete WordPress page. This is the reason for the site speedup, as it bypasses all the other plugin or shortcode processing.

The plugins like ‘country-filter’ are dynamic in nature, depending on the IP address of the client to deliver dynamic content. Integrating this with a cache plugin means that one way or the other the cache plugin will have to execute a plugin code to get the dynamic data, rather than the cached static page, which in itself defeats the basic idea of a cache.



February 10th, 2012 at 1:51 am

Thanks for your detailed answer re cache




March 16th, 2012 at 7:18 am

Could this plugin detect the country of the visitor and then dispays ads depending on that country?

Lets say I want to show CPA offers for US and othe offers for UK or other countries.

Can this plugin shows different offers for US, UK and so on?
If not do you plan to create this feature?



March 16th, 2012 at 8:53 am

Yes, it. Can do that. Check the documentation above.


March 16th, 2012 at 8:54 am

Yes, it can do that.



April 22nd, 2012 at 3:00 pm

i already bought your plugin and i already installed the pluggin succesfull. But i can’t find menu to setting. where can i find the menu?



April 22nd, 2012 at 4:13 pm

sorry to ask again.. how to use “Filtering other content” in widget. My purpose to bought your plugin is to filtering the adsense script on my widget, Now i want to ask how to use this script


// The content here is displayed only for users
// browsing from US, UK or Australia.

// People from other countries will see the content
// given here but not the above.


and where i should put the script in. sorry im so newbie about the coding.
and one more question. to use the script above which plugin i should use. is it “Country Filter ( ip2nation )” OR “Country Filter ( MaxMind GeoIPLite )”

Hope to hear from you soon





June 8th, 2012 at 5:28 am

I want to serve 5 pages from my site to be served to a specific country and other 5 to global visitors excluding the 1 country,what is the code and which plug in will it work with?


mustafa kırmızı

June 25th, 2012 at 11:44 am

ovv great!



September 27th, 2012 at 7:18 am


I would like to use the filter like this:

// The content here is displayed only for users
// browsing from US.

// The content here is displayed only for users
// browsing from The Netherlands.

// People from other countries will see the content
// given here but not the above.

So i want more seperate countries with different content plus general content for all other countries. Is this possible? if yes, how should the code look?

Thanks in advance!


September 27th, 2012 at 8:20 am

Check this sample code:



October 30th, 2012 at 1:09 am

This is exactly what I am looking for. Can the shortcode method hide or display a piece of HTML code? I am trying to hire a Paypal buy now button HTML code from certain countries. Thanks in advance.


October 30th, 2012 at 3:37 am

Of course you can show/hide HTML code using the shortcode method.



November 2nd, 2012 at 4:03 am


I would like to know if you have a affiliate link for your plugin ?




November 3rd, 2012 at 8:59 pm

At present the plugin does not have any affiliate links, however I’m planning to add one in the future.



November 9th, 2012 at 8:30 am

OK because I am interested to do an article on my blog in French. I would also like to use the plugin to display ads based on country.
Do not hesitate to tell me.




November 14th, 2012 at 4:49 am

Hello there! I just got the plugin, installed it and it ran fine for a while, before it completely killed my site and all I am getting now is internal server errors.

I am running a medium-sized blog (about 30,000 page views per day) on a dedicated server, but it seems that the requests are for much for it to handle. Is there any way to make it work?


November 14th, 2012 at 5:28 am


This should not happen, as it has been used for sites with in excess of 45000 users. Can you send your site url.



November 21st, 2012 at 2:43 am

It might have been just a coincidence – the plug-in worked fine since then until now, and yesterday I had over 50,000 page views. Now all it has to do is to grow and get a 99.9% rate :) Either way, good job!


cesar mejia

December 3rd, 2012 at 5:39 am

hi! which is the country code for Guatemala ?¿ Thank you!


December 3rd, 2012 at 7:02 am



January 10th, 2013 at 2:11 am


We have a press website (running on WordPress 3.5), where users can registrate without moderation. Now, we get a lot of post spammers from China and USA. Is it also possible to block /wp-login.php for different countries? And is it also possible to allow only 1 or 2 countries, or can we only disallow countries?



March 8th, 2013 at 9:29 am

Great job, it really works but Chrome doesn’t seem to have the will to obey. I forbade the vision of some video in my country but with Chrome I still can watch the restricted videos. Any advice?



August 11th, 2013 at 2:27 pm

Hi, maybe you can use this technique to make your plug-in work with WP super cache.

I would love to buy your plug-in if you finally make it.


September 5th, 2013 at 11:10 pm

hello.. is it possible to filter from all Asian country?


September 5th, 2013 at 11:12 pm

You will need to specify all the Asian country codes, which I can understand can be tedious. I’ll add the feature in the next version to filter by continents.


Søren Wahlgren

September 18th, 2013 at 1:21 am


I bought the plugin and I’m currently trying to implement it. I want to show a different affiliate link to people within and outside of the EU respectively. Can this be done without a mile long list of countries in the shortcode?


September 18th, 2013 at 2:10 am

Not at present as the plugin was primarily developed to filter between a few countries. However, I’ve received a few requests to filter by EU, continents etc, which I’ll implement in the coming version of the plugin.

Till then you will have to do by adding all the country codes in the shortcode. Will email you the new version once it is ready.


Søren Wahlgren

September 18th, 2013 at 9:26 am

The task wouldn’t be so difficult if one could just find a list of EU countries and non-EU countries to copy/paste in to the code. I’m currently looking for such a list and will post it here if I find one.



September 22nd, 2013 at 3:10 pm

I was wondering if there is a way to break it down further by filtering by state and or province (US and Canada)?


September 23rd, 2013 at 4:33 am

Not at present, but it is in the works and will probably be available in the next version or as a different plugin.



October 4th, 2013 at 1:15 am

Hi Sameer

this looks like exactly what we need (showing different footer and sidebar elements to different countries) but my concern is if we use the shortcodes to swap out page content will Google see this as cloaking?

Because it will see multiple content versions sitting on the same url. Could this then get us penalised?

I assume Google will see what is onscreen and not what is in the code? (actually if we are hiding content does it still appear in the source code or does it get removed before appearing in the browser?)

This seems to be my only concern as I have an international client who is reliant on seo and this could be crippling.

many thanks



October 4th, 2013 at 6:17 am

Honestly, with such quick changes in Google algorithms it is hard to know. As now many leading sites rearrange content depending on the users country maybe Google will turn a blind eye to the issue. Than again, if your clients site is heavily dependent on SEO, I’d suggest you research some more. I’ll also check from my side.


Profesor Yeow

January 14th, 2014 at 10:10 am

Works with WordPress 3.8+ ??
Ask me please, I thinking in buy it :) Thanks!


January 14th, 2014 at 10:06 pm

This has been tested with WordPress 3.8+.



January 27th, 2014 at 7:40 pm

I too wish to know if this plugin is compatible with wordpress 3.8+ and is well supported and updated.


January 27th, 2014 at 7:43 pm

Yes Andrew, it has been tested upto 3.8



February 3rd, 2014 at 5:18 am


I think I am looking for a plugin like this.
I have some questions:

I would want to show Adsense to some country visitor and other banners to visitors from other countries. Can I do that with this plugin?

Does it work with WP Super Cache?

On the other hand, I would want to know if there is any demo version to try it, because I have bought some plugins that finally didnt worked or they werent what I espected, so I want to try it before buying it.

Thank you!


February 3rd, 2014 at 8:09 am

1. You can accomplish the point mentioned.
2. No, this does not work with any cache plugin.
3. There is no demo version to try.



February 19th, 2014 at 3:25 pm

I keep getting this error on activation… I followed your instructions, and still have the error.

Warning: require_once( failed to open stream: No such file or directory in /var/www/vhosts/ on line 32 Fatal error: require_once(): Failed opening required ‘’ (include_path=’.:’) in /var/www/vhosts/ on line 32



March 1st, 2014 at 8:11 am

Does your plugin work with Wp Minify plugin or any minify plugin?


March 2nd, 2014 at 8:37 pm

Yes, it works with the WP Minify plugin.



March 23rd, 2014 at 7:22 pm

Hi, just bought your plugin. in your instructions you say to download a file here:
This returns the message “invalid archive directory”. I’ve taken a look at their website but really have no idea what i’m looking for. Please advise.


March 23rd, 2014 at 7:45 pm

Hello Sarah,

I’ve sent the 2 files to your email id.



March 28th, 2014 at 7:47 pm

Hello! First of all the plugin worked like a charm. I do see one issue and I’m not sure what I can do about it. When I used my safari browser on my phone, it displays properly. When I click on the link within facebook, it shows the american content, even though I am in Canada. Is there any way to get around this?


March 28th, 2014 at 8:58 pm


Really not sure what you are saying. Can you please give me your site url.



March 28th, 2014 at 9:59 pm

What is your email? I can send you the details there.


March 28th, 2014 at 10:01 pm



March 31st, 2014 at 12:22 am

Hi, probably a silly question, but wondering if there is any way i can check my code. If I’m blocking something from appearing in my country, or only in another country, then i can’t see that it’s really there if you see what i mean. Is there a workaround?


March 31st, 2014 at 7:36 am

You need to use some online proxy servers that route your website traffic from a selected country of your choice. This enables you to verify if the code works correctly.



April 16th, 2014 at 12:15 am


Very excited about the plugin and you seem on the ball with support!

I am going to purchase it today and use to display widgets that contains Double Click for Publishers (the google adverts) based on country codes as some of the sizes the client wants is only for certain countries.

REF Sarah – She can use Hidemyass, I can give a link if required and they have super loads of countries it works best to test this.

Hope I get it setup the first time correctly lol



April 16th, 2014 at 12:41 am

Does your plugin work with MUltisite?


April 16th, 2014 at 12:50 am

Honestly, have not tested on multisite.



April 23rd, 2014 at 7:10 am

Hi Sameer,

I just bought and installed the plugin plus the geo IP stuff but content within the shortcodes is not displaying correctly. When I set display=”0″, the content within the shortcode displays and when I set display=”1″, the content his hidden, regardless of country. It seems to be the reverse of what should happen, and it doesn’t seem to be picking up any geoIP value. Do you know what i’m doing wrong? Are there further settings required than installing the plugin and the two geoIP files? Any help you can give would be great!



April 23rd, 2014 at 7:28 am

Check if any cache plugin are activated. The plugin does not work with cache plugins : wp-supercache etc.



April 24th, 2014 at 12:59 am

Hi Sameer,
I have no cache plugins in operation at the moment – do you know if there have been other cases where similar problems have happened, or what else I can check to try to get Country Filter working?

Currently I have Akismet, Gravity Forms and a few custom-post and shortcode plugins, as well as Revolution Slider and Yoast SEO. None of these seem a likely cause, and I need to keep them active anyway.

Any help you can give would be great!



April 24th, 2014 at 5:36 am

If you read the documentation above:

…People in other countries will not be able to see the string. On the other hand, setting the display attribute to ’0′ will hide the content for users in US and India but will display the string to people from other countries as given in the following code. …

The plugin is working correctly, most probably your IP is behind a proxy and is returning an incorrect location. This happens many times for proxy servers.

Can you set a certain page to display some text and add the country code ‘in’ to the shortcode so I can check from my side.



April 26th, 2014 at 11:51 am


iControlWP have a good plugin that can disable W3TC cache plugin to stop working while using custom content for each country .

Why don’t you add a same feature to your plugin??




April 26th, 2014 at 12:00 pm

And can I tell the plugin to update database on monthly basis ?



April 26th, 2014 at 12:01 pm

And can I tell the plugin to update the IP 2 country database on monthly basis ?


April 26th, 2014 at 10:35 pm

Currently you have to do that manually, but the next version will include the feature. But that is a few months away.


jump manual scam

May 13th, 2014 at 5:06 pm

Great information. Lucky me I came across your site by chance (stumbleupon).
I have saved as a favorite for later!



August 1st, 2014 at 11:55 am

How can I update from 1.5.1 to 2.0?



August 2nd, 2014 at 10:37 pm

Hiya! Quick question that’s completely off topic.
Do you know how to make your site mobile friendly?
My website looks weird when browsing from my apple iphone.
I’m trying to find a theme or plugin that might be able to
resolve this issue. If you have any suggestions, please share.


August 4th, 2014 at 10:04 pm

The best way is to use a responsive theme.


August 4th, 2014 at 10:07 pm

Juergen, if you have already bought the plugin, please send me your purchase reference number and I’ll send you the updated version.


Kier Heyl

August 29th, 2014 at 8:26 am

Is there a way to allow the user to select a country/region by a drop down, and then have the content dynamically update based on that user’s selection instead of their IP address?



September 8th, 2014 at 2:44 am


Am meeting this error when I try to activate.

Fatal error: Cannot redeclare geoip_country_code_by_name() in /home/skyhighdev/public_html/wp-content/plugins/country-filter/ on line 1593

Any thoughts?


September 8th, 2014 at 3:54 am


This is caused by some other plugin on your site using the same function (geoip_country_code_by_name), hence causing the conflict. I’ve modified the ‘’ file to resolve the conflict.

Resolution sent to your email.



November 13th, 2014 at 3:24 am

Hi Sameer
I installed your plug in to serve ads only to readers in the US and Canada.
I extracted and uploaded the GeoIP.dat and file only to the plugin directory, without the rest that came with the download.

I have added the shortcode to a sidebar widget and on my homepage using the.

[country-filter code=”us, ca” display=”1″]
ad code

On post pages and category pages I used the php code.

However the ads seem to be showing up on some pages and some times appears on the sidebar, not on the homepage. Could I have installed it incorrectly?


November 13th, 2014 at 3:30 am

You have added the correct short code. Make sure you do not have any cache plugin enabled. The current filter will not work if the pages are cached.



November 13th, 2014 at 6:44 am

I don’t use a caching plugin but I am using Managed WP hosting and they do have global CDN, Varnish and caching. Will that affect the country filter plugin?


November 13th, 2014 at 7:28 am

A CDN will most probably interfere with the proper execution of the plugin as the CDN will cache pages at different locations.



November 13th, 2014 at 8:34 am

Oh shoot. Then this won’t work for me. Do you have a refund policy?


November 13th, 2014 at 8:36 pm

Don’t lose heart. As I said it will probably not work. We aren’t 100% sure. Can you send me your site address and also can you add the following lines to a blog post a the end so that I can check if the content is visible from my end. This will display the characters ‘ -:- ‘ which will be hardly visible to your customers but will help me test it.

[country-filter code=”in” display=”1″]



January 1st, 2015 at 6:32 am


Can the Country Filter be customized to City Filter also. Pls let me know




January 4th, 2015 at 5:09 am

Currently it cannot be used to filter by city.



January 20th, 2015 at 1:31 am

Hi Sameer,

I have the same question as Kier Heyl (136)

Is there a way to allow the user to select a country/region by a drop down, and then have the content dynamically update based on that user’s selection instead of their IP address?



January 20th, 2015 at 1:42 am

Not at present, but I’m planning on implementing it in the future.



January 30th, 2015 at 3:42 pm

Hi, Looking interesting. Will this plugin work on Nginx app server?

Let me know.



February 2nd, 2015 at 2:52 am

If your current WordPress installation works flawlessly with Nginx than the plugin will also.



February 5th, 2015 at 5:56 pm

Hi, is there a option for a City Filtrer?
I only work in spain, and I nedd show diferents image depending of the diferent city.
I hope your answer.



February 5th, 2015 at 6:01 pm

Now I have seen post N 145 of RAJESH.
You told him “Currently it cannot be used to filter by city.”
But Do you are working in that?
When users can have this option?
1 month?
6 month?
1 year?


February 5th, 2015 at 6:25 pm

Not within 1 month for sure, but will be available in the next 6 months. Actually the problem lies with the db size for cities,which is kind of huge compared to the countries database.



February 6th, 2015 at 1:28 pm

Hi sameer.
Thank’s for your answer.
I’m not informatic but I understand what you mean.
Only two suggestion in order to make a good plugin:
1. The City option must include a radius where administror can introduce radius value (ex 50 km.). So, picture will showed also at the users next to the “CITY”.
2. The administrator interested in “CITY OPION” in the 90% of case only works in a specific state. For ex. I am working in spain, and I need “CITY OPION” only for spain. Maybe also for argentina. But I don’t need “CITY OPION” everywhere.
So maybe you can solve the size of data base, offering especific “Cities of Country addons”. So for exemple I only installe “Cities of Spain addon”. I don’t need the other cities…
Do you understand what I sayd?
I hope your news about that.
Good work.



February 7th, 2015 at 12:19 am




March 25th, 2015 at 3:01 am

I wanted to know if I can differentiate between mexico, peru, argentina, spain and global?


March 25th, 2015 at 11:29 am

yes, you can do that.



March 29th, 2015 at 11:10 pm

I dont know why this plugin doesnt work on my website. The country code doesnt, the visibility is only control by display=””, content hide if it is 1, content show if it is 0, no matter what country code put. For example my current location is in UK, and I put
[country-filter code=”gb” display=”1″]
This doesnt show anywhere, even I am in uk. Change display to “0”, now content is showing to all countries (checked on VPN)

Could you please help?


March 30th, 2015 at 9:31 am

VPN will give inconsistent results. Use some other computer to check. Also you can use to test if the country is showing correctly in the browser. Disable any WP caching plugins.


EIleen Schmidtke

March 30th, 2015 at 7:17 pm

Hi I have tinkered with an older plugin called Content by Country but it seems a bit limited and Im having issues trying to get it to work (it used to work). I am interested in purchasing this plugin but what I really need it to do is swap out menu items using the WP built in menu functions. Can this be done with this plugin and are you able to offer any support on how to get it to fork. An example would be a person in the US will see a vertical menu with 6 items (products) but a person from UK will have 7 items available (products) which will be the original 6 plus one additional unique to UK. Thanks. -Eileen


March 31st, 2015 at 9:52 am

You could use the ‘isCountryInFilter‘ PHP function in the plugin to do that (look at the example above). However, I’m at present not free to support any coding.



April 6th, 2015 at 9:45 pm

Hi i want to buy plugin. But ı use quick adsense for banner ads and ı want to target ads by countries. But i want to know that it is compatible or not with quick adsense widget ?


April 7th, 2015 at 10:10 am

Just tested and it works. For example to display ‘Ads1′ in a particular location in the post one could use the following:

[country-filter code=”us, in” display=”1″]

This will display the particular ad for only people from US and India. To display to all people and ONLY hide for users in US and India:

[country-filter code=”us, in” display=”0″]

Note that you will need to manually add this in the post or pages where you want to control the ad display. Automatic insertion of ads by Quick Adsense will not use country filter.



April 16th, 2015 at 2:52 pm

I have a question
I have purchased and installed the plugin, I’ve configured to filter by these countries (us, mx, co)
But the statistics I see that there are visitors from other countries of the world … How is this possible?
Is the plugin works well?


April 16th, 2015 at 3:32 pm

The plugin adds hits from all countries and not only those configured.


EIleen Schmidtke

April 16th, 2015 at 7:42 pm

Hello, I bought your plugin and activated it. When I use it on my page for first time it does not work. I get the following errors:

Notice: Undefined index: export_data in /Applications/MAMP/htdocs/corpak-local/wp-content/plugins/country-filter/country-filter.php on line 37

Warning: Cannot modify header information – headers already sent by (output started at /Applications/MAMP/htdocs/corpak-local/wp-content/plugins/country-filter/country-filter.php:37) in /Applications/MAMP/htdocs/corpak-local/wp-admin/post.php on line 233

Warning: Cannot modify header information – headers already sent by (output started at /Applications/MAMP/htdocs/corpak-local/wp-content/plugins/country-filter/country-filter.php:37) in /Applications/MAMP/htdocs/corpak-local/wp-includes/pluggable.php on line 1178

Can you please help? thanks.


April 16th, 2015 at 8:00 pm

Disable debugging in WordPress if it is enabled, in ‘wp-config.php’.

define(‘WP_DEBUG’, false);

Also you can do the following. In the CountyFilter plugin file. Change the line causing the notice, which is the following:





EIleen Schmidtke

April 16th, 2015 at 9:23 pm

Thanks Sameer for getting back to me. I changed the line you suggested and the error went away so Im hoping I am good to go. However, I am still working on my local install (in use) and was wondering if I can test it from here or if I need to test it on a live site?


EIleen Schmidtke

April 16th, 2015 at 9:44 pm

Nevermind, I just installed on live site and it seems to be working! Cool! I didn’t seem to need to alter the code as I did on my local install either. Thanks Sameer, very excited to start using this!



April 21st, 2015 at 5:07 pm


Do you have your plugin updated ? I have an error whenever i refresh the page

Notice: Undefined index: export_data in /usr/local/pem/vhosts/user/webspace/httpdocs/ on line 37 Warning: Cannot modify header information – headers already sent by (output started at /usr/local/pem/vhosts/user/webspace/httpdocs/ in /usr/local/pem/vhosts/user/webspace/httpdocs/ on line 1178


April 21st, 2015 at 7:48 pm

As mentioned in the comments before, In the CountryFilter plugin file, change the line causing the notice, which is the following:






April 21st, 2015 at 10:01 pm

Thank you and sorry I didn’t read previous comments, best.



May 13th, 2015 at 1:46 pm

As I can use?
if (! isCountryInFilter (‘us’)) {

That’s right?


Eileen Schmidtke

May 21st, 2015 at 3:03 am

Hi Sameer,

Is there a reason why your template code would not work in the footer of a 404.php page? Im using it to conditionally display loops (via get_template_part()) based on IP and it works great on even page except there are no post titles displayed at all on my 404 page. Weird…

Any ideas would be much appreciated. Thanks.

Here is the General code but you can check my website to see what I mean.



June 10th, 2015 at 4:25 pm


I bought your plugin and try to install, but error:

Warning: require_once( [function.require-once]: failed to open stream: No such file or directory in …/wp-content/plugins/country-filter/country-filter.php on line 32

Could you help please?


June 10th, 2015 at 10:03 pm

Please follow the installation instructions provided in the PDF.

Your thoughts

Sign up for fresh content in your email