This module registers custom conditions in Oxygen using which elements can be selectively output based on various parameters.

The colored label next to the condition name in the plugin’s name indicates the category under which it will get added in the Oxygen’s conditions dialog.

    Archive Type

    Registers a custom condition to control the output of elements on archive pages based on the archive type.

    Available Archive Types

    Posts page (Blog): This is the blog posts index.

    Category: Any category archive.

    Tag: Any tag archive.

    Taxonomy: Any taxonomy archive page.

    Search: Search results archive page.

    Author: Any author archive page.

    Date: Any date archive page.

    Shop/Product Category/Product Tag: WooCommerce Shop or any WooCommerce product taxonomy archive.

    Use Case Example

    Say you have the blog posts index appearing on your site’s homepage (the default setting in WordPress).

    You have set up a Oxygen Template that applies to all archives and the blog posts index.

    You then added a Section having the archive title heading and do not want this to be shown on the Posts page (i.e., Blog or the homepage, in this case).

    Just add the custom condition shown below, select the Section, add a “Archive Type” Condition, set the operator as != and select Posts page (Blog).

    This will output the archive title heading section on all archives but the Blog.

    At Least 1 Search Result

    Allows you to conditionally output elements depending on whether there is at least one search result or not.

    For use in the Template that applies to search results.

    The condition lets us conditionally output elements depending on whether there is at least one search result or not.

    Use Case

    This condition can be used in conjunction with the How to create a Search Results page in Oxygen tutorial so that a message can be shown when there are 0 search results.

    When there’s at least 1 search result:

    When there’s no search results:

    To set this up, you would move everything inside the Template for search results from the other tutorial inside a Div and set this condition on that Div:

    After that you would create another Div alongside (at the same level as) the earlier Div and add Heading/Text/Search Form telling the user that there are no results for the term they searched for. Then you’d apply the condition on this Div like so:

    Author has CPT entry

    Registers a custom condition using which elements can be output only if the current user is logged in, is an author and has at least 1 published entry of the Custom Post Type to be set in the condition.

    Update: Also added != operator.

    For a possible use case for this condition, see this Facebook post.

    In the Oxygen editor (view does not matter i.e., you could be editing any entry or any Template) select your desired element for which you wish to apply the condition. Add the condition and select your post type to check against in the right dropdown.

    Body Class

    This module registers a custom condition using which elements can be output depending on whether the current page’s body has the given class or not.

    Any element to which this condition is applied will only be output if “page-id-23” is one of the body classes for that page

    Both == and != operators shall be set so that it is possible to check if the page either has or not has the entered class.

    Use Case

    Let’s say you want to show a section only on all single posts but not the rest of the pages on your site.

    Inspect any single post with your browser DevTools and look for the body tag. It could be something like this:

    <body class="post-template-default single single-post postid-299 single-format-standard  wp-embed-responsive theme-oxygen-is-not-a-theme oxygen-body woocommerce-js oxygen-aos-enabled" data-aos-easing="ease" data-aos-duration="400" data-aos-delay="0">

    The single-post class is unique and common to all the single post pages in WordPress.

    So you could enter it for the class name in your condition for the Section and the Section will be output only on all single posts in the front end.

    Similarly WordPress provides useful classes for different views. You can find the list here.

    Browser Detect

    This module registers a custom condition named Browser using which elements can be set to be output conditionally depending on the visitor’s browser.

    These are the browsers available in the condition’s value dropdown:

    • Brave
    • Chrome
    • Firefox
    • Edge
    • Internet Explorer
    • Opera
    • Safari
    • Safari on iPhone

    Operators available: = and !=.

    This plugin uses Browser.php by Chris Schuld for browser detection.

    Note: Browser detection using PHP may not (always) work especially when caching is present. You are advised to test this plugin before investing a lot of time and energy in creating browser-specific Sections.

    Country

    Registers a custom condition for geo-targeting your visitors based on their country.

    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.

    Caveat

    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.

    With the element/component you want to geo-target selected, click the Conditions icon and set the Country condition.

    Note

    In the PHP code we added in the Snippets, we are making a call to geoplugin.net over http and not https.

    While this does not show security errors in the JS console or make pages of your site insecure, depending on your needs and budget you may want to opt for a paid Geo IP service that lets you use their API for showing the visitors’ country.

    A few options:

    smartip.io
    250,000 IP requests / mo
    8333 per day

    ipapi.co
    1000 free calls per day

    ipdata.co
    1500 free calls per day

    CPT Has At Least 1 Published Entry

    Allows you to conditionally output elements only if the specified Custom Post Type has at least one published entry.

    Current CPT Author

    Allows you to conditionally output elements on single pages of Custom Post Types if the CPT single page being viewed is by the author of that entry.

    For use in the Template that applies to singular entries of a CPT.

    Apply the condition on elements that you wish to be output only if the currently logged in user is the author of the current CPT single page.

    Is Child

    Registers a custom condition using which elements can be output on the front end only if the current single page being viewed is a child i.e., has a parent.

    Works on single views of any post type.

    It is also possible to check if the page is a parent page by selecting the false operator.

    Is Child of a Specific Page

    Registers a custom condition using which elements can be output only if the current Page is a child of the selected Page.

    For use when editing a static Page or a Template that applies all the Pages.

    With the above in place, only if the current Page is a child or sub page of “About” Page will the element be output on the frontend.

    The list of Pages will be populated in the right side dropdown.

    Is Homepage

    Allows you to conditionally output elements depending on whether the current page is the homepage or an inner page.

    For use in the Template that applies to all Pages.

    This works regardless of whether the homepage is a static Page or the default blog posts index.

    In Oxygen editor, select any element for which you wish to apply the condition and click on the Condition icon.

    Add the condition and select true to make the element be output only on the homepage and false to make it output everywhere except the homepage.

    Language

    Registers a condition using which you can conditionally output elements based on the user’s language.

    The language is the one that the user’s browser relays to the server of your website.

    To check against multiple languages, set the condition type to OR and add multiple conditions as needed.

    Ex.:

    The list of languages present in the condition can be seen here.

    To know what the language(s) of the user has/have been set to, you could ask them to tell you the output of

    $_SERVER["HTTP_ACCEPT_LANGUAGE"]

    MemberPress Membership

    Register a custom condition using which elements can be output conditionally based on whether the user has purchased/subscribed to a membership using MemberPress.

    To check against multiple membership products, condition type can be set to OR.

    Both == and != operators are made available meaning, it is possible to output elements based on whether the currently logged in user has or has does not have access to the selected membership(s).

    Mobile Detect

    Allows you to conditionally output elements for various devices like mobiles, tablets, iOS, Android.

    This condition users the Mobile_Detect PHP library which uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.

    Caveat

    Detection of device using PHP is not reliable and may not work especially when caching is active. You are advised to test this in a staging/dev site before depending on this in production.

    iPads do not get detected under “Tablet” condition anymore. Details.

    Details

    This option adds all the following conditions:

    Month

    Registers a condition using which elements can be set to be output (or not be output) during specific month(s).

    For example, if you set the following for a Section, the Section will be output or printed on the front end only when the page is being viewed on any day of September of the current year.

    Post ID in Array

    Allows you to output elements on single posts (of any post type) only if the current post’s ID is in the array of supplied IDs.

    For use in the Template that applies to a singular post of any post type.

    Edit the Template that applies to Singular Post (the standard ones or of any CPT) with Oxygen.

    Add/use the condition. It will be present under Post.

    For the value, enter comma separated (with or without space) of post IDs.

    Show IDs plugin adds the IDs admin column and makes it easy to see the IDs on posts list screens in the WordPress admin.

    Note: It is also possible to use multiple built-in Post ID conditions (with OR) instead of using this condition if you want.

    Post Password Protected

    Allows you to password protect the entire content of single pages (Pages or Posts or CPTs) including the content coming from the Oxygen editor.

    Typically used in the Template that applies to a singular post of any post type.

    Step 1

    Edit the Oxygen Template that applies to your desired post type.

    In this example, let’s use the Template that applies to all static Pages.

    Open the Structure Panel.

    You may currently have it like this:

    Select the outer Inner Content.

    Add a Div and move whatever you currently have in the Template under this Div.

    Select the Div and apply

    Post Password Protected == false

    condition.

    Select the outer Inner Content and add a Section.

    Add a Code Block inside the Section having:

    <?php echo get_the_password_form(); ?>

    Select the Section and apply

    Post Password Protected == true

    condition.

    While it does not matter, you might want to move the Section to be present above the Div.

    The final structure should be like this:

    Step 2

    To password protect a Page edit the Page and use the Post Visibility setting in the Status & Visibility meta box.

    Don’t forget to Update the Page.

    Referrer URL Parameter

    Registers a custom condition using which elements can be output based on the value of specific URL parameter like /?referrer=facebook.

    Use Case

    Let’s say you want to output a section having for example, a welcome message on the front end only for users that visit your site from Facebook and you want to output another Section only for visitors that land on your Page after clicking through a link in Twitter.

    To achieve this personalization, you would

    1. set condition for your Oxygen sections i.e., enter facebook as the value of referrer URL parameter for the Facebook section and twitter as the value of referrer URL parameter for Twitter section.
    2. use referrer query variable in your URLs like example.com/?referrer=facebook and example.com/?referrer=twitter

    Usage

    In the Oxygen editor add a Section that you want to be output to visitors that reach your page after they click on a link (to the page in question) having /?referrer=facebook in its URL.

    For example, let’s say the page in question is

    example.com/sample-page/.

    Share a link to this page as

    example.com/sample-page/?referrer=facebook

    in your Facebook campaigns/messages etc.

    Add whatever (Heading, Text etc.) you want to be printed for the above Facebook visitors on the front end inside this Section.

    Set a Condition for this Section.

    Enter facebook (the same query string value we have set in our Facebook URLs) as the value.

    Now this Section’s HTML will only be output to those that land on /?referrer=facebook.

    Repeat this process for any other URL parameter values as needed.

    So an element with

    applied to it will only be output if /?referrer=twitter is present in the page URL.

    RCP Membership

    Registers a custom condition using which elements can be ouput depending on whether the current logged in user is an active member of a specified membership level when using Restrict Content Pro or not.

    Use Case Example: You have a membership level in RCP called “Premium”. You have a Section in a Template/Page that should only be output on the front end for members who have paid/subscribed to the “Premium” membership.

    Select the Section, click on the Conditions icon, add a new condition, select “Restrict to active members of a specific membership level (enter ID)” and specify the ID of your membership level (1 in this case).

    Once done, this Section will not be printed on the front end for users that don’t have active access to your membership level.

    US State

    Allows you to output elements to users visiting from a specific state in the US using the API from ipapi.co.

    We are going to add “US State” in the conditions list under the “Geo” 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 US state.

    Note: You can easily modify this to check against regions (states) of any country by replacing the state names in the code.

    Use Case

    Say you own a tours attraction website based in the US. You could show one Section for visitors from New York and another for visitors from a different state say, Florida.

    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 or shown using CSS’ display property.

    Caveat

    IP and State detection may not work reliably when there is caching (especially at the server level) involved. You may need to add the page(s) where you are implementing this to your cache plugin’s exclusion list.

    You are advised to test this solution first before using it in production.

    WLM membership(s)

    Allows you to output elements only if the currently logged in user belongs to the selected membership level when using WishList Member.

    To check against multiple membership levels, condition type can be set to OR.

    Both == and != operators are made available meaning, it is possible to output elements based on whether the current logged in member belongs to or does not belong to the selected membership(s).

    Apply the condition to any element in Oxygen that should be shown or not shown to members based on the membership level they belong to.

    WooCommerce

    This option adds Woocommerce-focused conditions put together by David Browne to help you build more dynamic e-commerce sites.

    The conditions under Woo Product category apply to single product pages.

    Product Type

    This condition can be used to check if the product is simple or grouped or external or variable. Available operators are == and !=.

    Product in Category

    This condition can be used to check if the current product belongs to a specific product category or not.

    Product has Tag

    This is similar to the above condition but for product tags instead of product categories.

    Product on Sale

    This condition can be used to check if the current product is on sale or not.

    Product is Virtual

    This condition can be used to check if the current product is a virtual product or not.

    Product is Downloadable

    This condition can be used to check if the current product is a downloadable product or not.

    Product has Image

    This condition can be used to target products based on whether they have a product image set or not.

    Product in Stock

    This condition can be used to target products that are in stock or not.

    Product Already Purchased

    This condition can be used to check whether the currently logged in user has already purchased the current product or not.

    The conditions under Woo User category apply to currently logged in user.

    Has Empty Cart

    This condition can be used to check whether the current user has any products in his/her cart or not.

    Has Product in Cart

    This condition can be used to check whether the current user has the selected product in his/her cart or not.

    Has Cart Weight <weight unit>

    This condition can be used to check the weight of items in the user’s cart against a specified value. All the math operators like ==, !=, >=, <=, > and < are available.

    Is at Endpoint

    This condition can be used to check whether the user is at one of these or any of these endpoints:

    • Order Pay
    • Order received
    • View order
    • Edit account
    • Edit Addresses
    • Payment methods
    • Lost password
    • Customer Logout

    Has Purchased Product

    This condition can be used to determine whether the current user has purchased the selected product or not.

    Has Cart Total <currency symbol>

    This condition can be used to check the cost of items in the user’s cart against a specified value. All the math operators like ==, !=, >=, <=, > and < are available.

    Selected Tag has at least One Product

    This condition lets you output any element if the selected product tag has at least one product assigned to it. Product tag name can be selected from the condition’s right-most dropdown.

    Selected Category has at least One Product

    This condition lets you output any element if the selected product category has at least one product assigned to it. Product category name can be selected from the condition’s right-most dropdown.

    At least One Featured Product

    This condition lets you output any element depending on whether or not there is at least one (published) featured product.

    At least One Product on Sale

    This condition lets you output any element depending on whether or not there is at least one (published) product on sale.

    Top