Skip to content

Rental availability table in WordPress

Week-by-week availability for a holiday rental or equipment: status written out, a filter for free weeks, picking a week and sending a booking request.

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

pattern.html
<!-- wp:html -->
<form class="tdl" data-tdl aria-labelledby="tdl-titre">
        <p class="tdl-eyebrow">Gîte du Moulin · 6 personnes · Dordogne</p>
        <h2 class="tdl-title" id="tdl-titre">Disponibilités de l’été 2027</h2>
        <p class="tdl-lead">Location du samedi au samedi. Une option posée est gardée 5 jours : elle peut se libérer.</p>
        <label class="tdl-filter"><input class="tdl-check" type="checkbox" data-tdl-filter><span>Afficher seulement les semaines libres</span></label>
        <p class="tdl-count" role="status" data-tdl-count>10 semaines affichées, dont 4 libres</p>
        <div class="tdl-scroll">
          <table class="tdl-table">
            <caption class="tdl-sr">Disponibilités par semaine, du 26 juin au 4 septembre 2027</caption>
            <thead>
              <tr>
script.js
(() => {
  if (!document.querySelector(".tdl")) return;
  document.querySelectorAll("[data-tdl]").forEach((root) => {
    const on = (el, type, fn) => el.addEventListener(type, fn);
    const form = root;
    const weeks = [...root.querySelectorAll("[data-tdl-week]")];
    const filter = root.querySelector("[data-tdl-filter]");
    const count = root.querySelector("[data-tdl-count]");
    const summary = root.querySelector("[data-tdl-summary]");
    const picked = root.querySelector("[data-tdl-picked]");
    const sent = root.querySelector("[data-tdl-sent]");
    const free = weeks.filter((week) => week.dataset.tdlStatus === "libre").length;
style.css
:root {
  --tdl-card: #fffdf8;
  --tdl-text: #2a2117;
  --tdl-muted: #5f5243;
  --tdl-line: #e6dccd;
  --tdl-soft: #f6efe3;
  --tdl-accent: #9a3412;
  --tdl-accent-text: #ffffff;
  --tdl-free: #166534;
  --tdl-free-bg: #dcfce7;
  --tdl-busy: #4b5563;
  --tdl-busy-bg: #eceae6;
tableau-disponibilites-location.php
<?php
/**
 * Plugin Name: Forge, Tableau des disponibilités d’une location
 * Description: Les disponibilités d’un gîte ou d’un matériel semaine par semaine : état écrit en clair, filtre des semaines libres, choix d’une semaine et demande de réservation. Ajoute la composition « Tableau des disponibilités d’une location » à 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-tableau-disponibilites-location
 *

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