How to retrieve opening hours attribute value?

I am creating a code snippet where I am retrieving listings’ information including title, image, rating, attribute values and so on. I am able to retrieve those but I am not sure how should I go about retrieving the values of HivePress Opening Hours stored in a listing? I am creating a custom listing slider with the help of AI and everything seem to be working but I am not able to retrieve the hours information, specifically when a listing is set to open 24/7. Can you please provide some information about how the open 24/7 value in HivePress Opening Hours are stored for each listing, thanks.

P.S. I am using multisite setup.

Hi,

To retrieve the opening hours data, use $listing->get_opening_hours(). This will return an array containing the values the user filled in (days of the week, with “from” and “to” times for each row).

However, if you need it formatted for display in HTML, it’s better to use $listing->display_opening_hours(), which returns the HTML table already formatted.

If you use display_opening_hours(), it already has the logic built in and will show “Open 24/7” instead of the table when that checkbox is checked. If you use the getter methods, you’ll just get the raw values and would need to handle the display logic yourself.

Hope I helped with your request.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.