Using Oxygen's Conditions to hide an element on your WordPress homepage

PUBLISHED 18 Nov 2020 - UPDATED 19 Nov 2020

The WordPress builder Oxygen has a fantastically useful feature called Conditions, which:

allow you to selectively display any Oxygen element based on a condition or set of conditions, such as if a user is logged in, or if a user has a certain role or capability.

When an element's conditions evaluate to true, the element is shown. If the conditions evaluate to false, the element is hidden

Oxygen has a whole host of conditions to choose from, relating to the Post, the User, the Author and so on. But recently I wanted I wanted to hide an element on my homepage only. There is no 'homepage' condition in Oxygen as such. So how could I achieve this?

If I was using a static homepage, it would presumably be easy - I could use the Post ID, Post Title or something like that. But in WordPress I had chosen the option "Your homepage displays Your latest posts" instead (under Settings > Reading):

Homepage displays latest posts

Luckily though, the Oxygen Conditions feature can also make use of WordPress functions. And WordPress has a built-in function called is_front_page() which returns true when viewing the site's front page (either a static homepage or a dynamic blog index as in my case).

Making use of this is pretty simple:

  1. Open up the Oxygen template that contains the element you want to conditionally display/hide (in my case, this was my reusable header template, which is used not just on the homepage but across the entire site)
  2. Select the element you want to conditionally display
  3. Click on the Condition Settings icon

Condition settings Oxygen

  1. Click on Set Conditions

Set Conditions Oxygen

  1. Click Add your first condition
  2. In the 'Choose condition...' dropdown, choose Dynamic Data

Dynamic Data

  1. In the 'Insert Dynamic Data' popup, choose PHP Function Return value
  2. In the Function Name field, add: is_front_page (you don't need brackets or any arguments)

PHP Function Return value Options

  1. Click INSERT
  2. The function will return '1' (true) on the homepage but will otherwise be blank. So to conditionally hide an element on the homepage only, change the '==' dropdown to is_blank. (Conversely, to show it on the homepage only, select is_not_blank).

Condition is_blank

  1. Close the 'Conditions' popup
  2. Remember to Save your template
  3. Now view your homepage and refresh your browser. The conditionally hidden element should now be... hidden!

Incidentally, WordPress has another similar function called is_home(), but I didn't have any success with this in Oxygen.

And for a more general overview of conditions in Oxygen, check out this official video:

Notify of
Inline Feedbacks
View all comments
3 years ago

Thank you, i was looking for this !

2 years ago

This is a better solution: than the raw conditions on their own. It creates much better more clear specificity.

ACF is on most sites or even Metabox could be used in a similar way.

1 year ago

Thank you ... just what I was looking for.

1 year ago

I have just a question. Do you know please, what does it mean, when I have in condition string settings_page=false? It appears when I choose something from ACF. Thank you.

James Clark
Hi! I'm James Clark and I'm a freelance web analyst from the UK. I'm here to help with your analytics, ad operations, and SEO issues.
What do you think? Leave a commentx
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram