This members-only tutorial provides the steps to register a custom condition for geo-targeting your visitors in Oxygen.

We are going to add "Country" in the conditions list under the "User" category with equals and not equals operators.

Meaning, you can either output or NOT output any element in the Oxygen builder to visitors from a specific country.

Also, by using the AND/OR feature of the Oxygen's conditions, you will be able to combine this for handling multiple countries if you wish.

Use Case

Say you own a tours attraction website based in the US. You could show one Section for visitors from the US and another for overseas visitors.

Note that the great thing about Oxygen's conditions is that content gets output or printed on the front end conditionally and it is not that it is just hidden and shown using CSS' display property.


IP and Country detection may not work reliably when there is caching (especially at server level) involved. You are advised to test the solution first before using it in production.

Step 1

Install and activate Code Snippets plugin.

Go to Snippets > Add New.

Title: [Functions] IP Address and Country


This is a premium members-only content.

To view the rest of the content, please sign up for membership ($37/month or $399 one-time).

Already a member? Log in below or here.

Need help implementing a tutorial in your site or want to hire me for custom work?


Find the article helpful and wish to donate?



For adding code blocks wrap the code in three backticks. Markdown should work.
Provide a URL of your site/webpage if something is not working.

2 comments on “[Condition] Country”

  1. Hey Sridhar, how well can this be used translating the pages instead of using TranslatePress / Polylang / WPML – performance-wise and how easy it would be to setup & use for all parts of the WP, taxonomies, alt tags, all the stuff?

    For localization, this could make wonders, different kind of images, tone, etc depending on the culture?

    1. I’ve been wondering the same thing .. detecting browser language shouldn’t be too hard – of course user preference should be respected so offering them a choice someplace would be nice.

linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram
%d bloggers like this: