Skip to content

Opening hours, address and access in WordPress

A “Visit us” section for local shops: weekly opening hours with today and the live opening status, address, ways to get there (tram, bus, car, bike, step-free access) and directions and call buttons.

Here is an excerpt of this component's code in WordPress. The full code is free for members, ready to copy into your project.

This component also comes in

Open in a new tab

The code in WordPress

features-zone-horaires-contact.php
<?php
/**
 * Plugin Name: Forge, Horaires, adresse et accès
 * Description: Une section « Nous rendre visite » pour commerce de proximité : horaires de la semaine avec le jour courant et l'état d'ouverture en direct, adresse, moyens d'accès (tram, bus, voiture, vélo, accès de plain-pied) et boutons itinéraire et appel. Ajoute la composition « Horaires, adresse et accès » à l'éditeur de blocs.
 * Version: 1.0.0
 * Requires at least: 6.6
 * Requires PHP: 8.1
 * Author: Forge
 * License: GPL-2.0-or-later
 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain: forge-features-zone-horaires-contact
 *
pattern.html
<!-- wp:html -->
<section class="fzh" data-fzh aria-labelledby="fzh-titre">
        <div class="fzh__head">
          <p class="fzh__eyebrow">Nous rendre visite</p>
          <h2 class="fzh__title" id="fzh-titre">Horaires, adresse et accès</h2>
          <p class="fzh__intro">Plus de quatre-vingts fromages affinés dans notre cave, à la coupe ou en plateau. Passez nous voir, ou appelez pour réserver votre commande.</p>
        </div>
        <div class="fzh__grid">
          <div class="fzh__card">
            <h3 class="fzh__h3"><svg viewBox="0 0 24 24" width="24" height="24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/></svg>Horaires d'ouverture</h3>
            <p class="fzh__status" data-fzh-status hidden><span class="fzh__dot" aria-hidden="true"></span><span data-fzh-status-text></span></p>
            <dl class="fzh__hours">
script.js
(() => {
  if (!document.querySelector(".fzh")) return;
  document.querySelectorAll("[data-fzh]").forEach((root) => {
    const names = ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"];
    const rows = [...root.querySelectorAll("[data-fzh-day]")];
    const week = {};
    rows.forEach((row) => {
      week[row.dataset.fzhDay] = row.dataset.fzhRanges ? row.dataset.fzhRanges.split(",").map((range) => range.split("-").map(Number)) : [];
    });
    const status = root.querySelector("[data-fzh-status]");
    const label = root.querySelector("[data-fzh-status-text]");
    const space = document.createTextNode(" ");
style.css
:root {
  --fzh-text: #1f1b16;
  --fzh-muted: #57504a;
  --fzh-card: #ffffff;
  --fzh-line: #e6dfd4;
  --fzh-accent: #8a4b08;
  --fzh-accent-hover: #6f3c06;
  --fzh-accent-soft: #fbeedd;
  --fzh-accent-strong: #5a3005;
  --fzh-on-accent: #ffffff;
  --fzh-open-bg: #dcfce7;
  --fzh-open-text: #166534;

Free component: copy it freely, including for commercial projects.

Features components in WordPress
  • Three cards in saturated flat colours (yellow, pink, electric blue) with high-contrast text and a dark variant. Every colour pair is measured at AA: 5.5:1 at worst.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • Six features as frosted glass cards over a slowly drifting aurora mesh gradient. Pause button, still background under prefers-reduced-motion, CSS and a light script.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • The key message stays pinned while the background changes colour and illustration at each scroll step. CSS sticky, a light script, stacked cards as fallback under prefers-reduced-motion.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A six-cell bento grid: key figures, SVG sparklines, a quote and icons. All the text is in the HTML and the animation is CSS only, with no script at all.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A two-offer table: checked rows, a column highlighted from top to bottom and one call-to-action button per offer. Pure HTML and CSS, no script at all.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A magazine-style article: title band, standfirst, drop cap, subheadings and a pull quote, set in three columns of equal height. Pure CSS, no script at all.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component