Adding a Geo based Conditional

Using Toolbox it is very easy to add any kind of filter. A location-based filter for instance is very easy to add.

You will need to install a plugin like GeoIP Detectection from the WordPress Repository.

When you’ve done so, you can add the following code to your functions.php or into your own plugin.

[pastacode lang=”php” path_id=”9ef5f21b42c9d2d3d5de43cda5919d2f/d9b94501e1611ba8c17dd79e0346671ed1b02937″ file=”toolbox_example_cond_filter_geo_detect.php” highlight=”” lines=”” provider=”gist”/]

You will be able to select the conditional from the dropdown list. By default it will check if the isocode is US, but you can check on any other isoCode. A complete list of isocodes can be found here.

Of course you can write your settings and conditional to check for multiple isocodes but this should get you started.


Web ninja with PHP/CSS/JS and Wordpress skills. Also stand-in server administrator, father of four kids and husband to a beautiful wife. Always spends too much time figuring out ways to do simple things even quicker. So that you can benefit.