I could use some help outputting opening hours from SEOmatic's Site Settings/Identity. The docs aren't clear on this, and the example at https://github.com/nystudio107/craft-seomatic/issues/843 doesn't work for me. Any help much appreciated.
1 Answer
Ended up just repurposing code from the plugin templates. This is working fine for me:
{% if seomatic.site.identity.localBusinessOpeningHours|length %}
{% macro day(value, day) %}
<tr>
<th>{{ craft.app.locale.getWeekDayName(day) }}</th>
<td>{{ value[day].open.date|date('g:ia')|replace({':00' : ''}) }}-{{ value[day].close.date|date('g:ia')|replace({':00' : ''}) }}</td>
</tr>
{% endmacro %}
{% from _self import day %}
{% set startDay = currentUser.getPreference("weekStartDay") ?? craft.app.config.general.defaultWeekStartDay %}
{% set days = (startDay..6) %}
{% if startDay != 0 %}
{% set days = days|merge(0..(startDay -1)) %}
{% endif %}
<table>
{% for i in days %}
{{ day(seomatic.site.identity.localBusinessOpeningHours, i) }}
{% endfor %}
</table>
{% endif %}