The same setting can also place the opening hours in the “more info” section of the search results, or in the marker pop-ups. On the same tab, “Show the current open / closed status?” adds whether the store is open right now, and “Hide days marked as closed in the opening hours?” leaves out the closed days. If “Hide the opening hours?” is enabled in the Store Editor section of the settings page, the opening hours aren’t shown anywhere.
If you build the search results template yourself with the wpsl_listing_template filter, the v3 example on that page already includes the opening hours, following the same setting.
For a custom template that doesn’t use the setting, include the ‘hours’ data in your template code:
| // The opening hours, only for stores that have them. | |
| $listing_template .= "\t\t" . '<% if ( typeof hours !== "undefined" && hours ) { %>' . "\r\n"; | |
| $listing_template .= "\t\t" . '<div><%= hours %></div>' . "\r\n"; | |
| $listing_template .= "\t\t" . '<% } %>' . "\r\n"; |
The opening hours come with their own markup, a table or a list, so they’re wrapped in a div instead of a p. The typeof check keeps the template working for stores without opening hours, and when “Hide the opening hours?” is enabled.