Skip to content

Holiday opening hours in WordPress

A table of end-of-year special opening hours that flags today’s row and sums up at the top whether the shop is open today or which special day comes next.

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

horaires-exceptionnels-fetes.php
<?php
/**
 * Plugin Name: Forge, Horaires exceptionnels des fêtes
 * Description: Un tableau des horaires exceptionnels de fin d’année qui signale la ligne du jour et résume en tête si la boutique est ouverte aujourd’hui ou quel est le prochain jour particulier. Ajoute la composition « Horaires exceptionnels des fêtes » à 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-horaires-exceptionnels-fetes
 *
pattern.html
<!-- wp:html -->
<section class="hef" data-hef aria-labelledby="hef-titre">
        <p class="hef-eyebrow">Fournil Saint-Roch · Montpellier</p>
        <h2 class="hef-title" id="hef-titre">Horaires des fêtes</h2>
        <p class="hef-summary" data-hef-summary hidden></p>
        <table class="hef-table">
          <caption class="hef-caption">Jours aux horaires exceptionnels, du 24 décembre au 2 janvier</caption>
          <thead>
            <tr>
              <th class="hef-head" scope="col">Jour</th>
              <th class="hef-head" scope="col">Horaires</th>
            </tr>
script.js
(() => {
  if (!document.querySelector(".hef")) return;
  document.querySelectorAll("[data-hef]").forEach((root) => {
    const on = (el, type, fn) => el.addEventListener(type, fn);
    const now = new Date();
    const today = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}-${String(now.getDate()).padStart(2, "0")}`;
    const summary = root.querySelector("[data-hef-summary]");
    const rows = [...root.querySelectorAll("[data-hef-day]")];
    const hours = (row) => (row.dataset.hefHours ? `ouvert de ${row.dataset.hefHours.replace("–", "à")}` : "fermé");
    const current = rows.find((row) => row.dataset.hefDay === today);
    // ISO dates compare as plain strings.
    const next = rows.find((row) => row.dataset.hefDay > today);
style.css
:root {
  --hef-card: #ffffff;
  --hef-text: #2b2118;
  --hef-muted: #5e5146;
  --hef-line: #ece3d9;
  --hef-accent: #9a3412;
  --hef-soft: #fbf5ee;
  --hef-today-bg: #fef3c7;
  --hef-today-line: #b45309;
  --hef-today-text: #78350f;
  --demo-horaires-exceptionnels-fetes-bg: #f3ebe2;
  --demo-horaires-exceptionnels-fetes-text: #2b2118;

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

Data tables components in WordPress
  • A documentation table showing where a kit or component has been tested (static HTML, WordPress, Elementor, Webflow, v0…), with status, last test date and a remark, filterable by status.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A table of the towns and postcodes a tradesperson covers, with response time and travel fee, filtered by search and by zone.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A timetable table sorted by column and filtered with level and free-place chips, whose rows each become a card on phones.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A filterable table whose visible rows export in one click to a CSV file that opens cleanly in Excel or LibreOffice.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A price table by service: one package to pick, options to tick, and the total with the estimated time recalculated on every click.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A product spec sheet as two-column tables in native collapsible sections, with a button to open or close them all.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component