Skip to main content

Dynamic Visibility condition based on Start and End time

Updated over a year ago

Static start and end time

To achieve this you need a custom code, which can be found here: Custom Code

Add the code to the functions.php file of your child theme or use the Code Snippets plugin.
In dynamic visibility we need to add two condition with relation AND, for example:

macros - Format date - now, H:i Greater than 08:00

macros - Format date - now, H:i Less than than 10:00

Start and end time from time metafield

To achieve this you need a custom code, which can be found here: Custom Code

Add the code to the functions.php file of your child theme or use the Code Snippets plugin.

To start we need to have two time meta fields with the open/close time

Then you'll be able to set the dynamic visibility for the needed elements due to the work time

Start Time:

Condition - Greater than

Field - your metafield name

Value - macros "Format Date String"

Be advised, if you set up condition in Listing template, Context will be "Current listing item object" and if it's current post page - context will be "default"

And End time:

Don't forget to set "OR" Relation

Result:

Did this answer your question?