If you find yourself building lots of versions of sections/elements and need to prevent some of them from being output on the frontend, here’s a quick way to do it.

All we really need to hide an element is to set a condition that we know will be false. This can take too much time clicking to set up the condition, choosing the operator and typing the value each time.

I’ve been using this code snippet to make the process a little bit quicker. (I’m still hoping something will get built into the UI to make this a one-click process, but this saves a few clicks).

This is the code we add to our code snippets;

if( function_exists('oxygen_vsb_register_condition') ) {
	
	oxygen_vsb_register_condition('Disable Element', array('custom' => false), array(''), 'false', '');
	
}

This will register a new ‘fake condition’. It has no parameters, it’s always going to be false no matter what.

The ‘disable element’ will appear at the very top of the conditions list for easy access. No conditions to set, just select ‘Disable Element’ then close the conditions modal.

All done

You can still use the condition settings of ‘Always Show’ and ‘Always Hide’ to toggle visibility inside the builder, knowing the element won’t be output on the front.

Simply remove the condition to allow the element to reappear on the site.

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

HIRE ME

Find the article helpful and wish to donate?

DONATE

Comments

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.
magnifiercross
>
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram
%d bloggers like this: