Show today's opening hours with CPT and ACF

I want to dynamically show the opening hours of today’s weekday.

I’ve created a CPT ‘Traders’ for which I want to have an ACF-field with its opening hours throughout the week. What I then want is only show the opening hours of that weekday, that if wanted folds out into the full opening hours.

Would anyone know how to do this?

There are several ways you can do this. Here are a couple of ideas:

  1. Using individual fields

A possible solution is to create a separate field for each weekday that is a simple text input field for the time period.

You can then load each weekday’s times into individual blocks inside the page/template and then use date based visibility conditions to show/hide them.

Screenshot 2023-09-03 at 16.57.46

  1. Using a repeater

Another possible solution is to use a repeater field containing a weekday selection field and a start time and end time field.

This would require adding some custom code to show/hide the correct weekdays because currently Cwicly doesn’t allow loading of selected repeater items:

1 Like

thank you so much! it worked for me, amazing

1 Like