Sortable results table in WordPress
The results of a race or competition, sortable by place, name or category, with the podium highlighted, the gap to the winner and the sort order announced.
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
The code in WordPress
<!-- wp:html -->
<section class="trc" data-trc aria-labelledby="trc-titre">
<p class="trc-eyebrow">Trail de la Côte de Granit rose · 21 km · 14 mars 2027</p>
<h2 class="trc-title" id="trc-titre">Classement général</h2>
<p class="trc-lead">Cliquez sur un intitulé de colonne pour trier ; un second clic inverse l’ordre.</p>
<p class="trc-sr" role="status" data-trc-status></p>
<div class="trc-scroll">
<table class="trc-table">
<caption class="trc-sr">Classement général, 10 premiers arrivants</caption>
<thead>
<tr>
<th class="trc-head" scope="col" aria-sort="ascending" data-trc-col="place">(() => {
if (!document.querySelector(".trc")) return;
document.querySelectorAll("[data-trc]").forEach((root) => {
const on = (el, type, fn) => el.addEventListener(type, fn);
const body = root.querySelector("[data-trc-body]");
const rows = [...body.querySelectorAll("[data-trc-row]")];
const status = root.querySelector("[data-trc-status]");
const labels = { place: "place", name: "nom", cat: "catégorie" };
let key = "place";
let dir = 1;
const value = (row, k) => (k === "name" ? row.dataset.trcName : k === "cat" ? row.dataset.trcCat : "");:root {
--trc-card: #ffffff;
--trc-text: #19202d;
--trc-muted: #4d5769;
--trc-line: #dde2ea;
--trc-accent: #be123c;
--trc-gold: #fff4cf;
--trc-medal: #7a4a00;
--demo-tableau-resultats-classement-bg: #eeebee;
--demo-tableau-resultats-classement-text: #19202d;
}
<?php
/**
* Plugin Name: Forge, Tableau de classement triable
* Description: Le classement d’une course ou d’un concours, triable par place, nom ou catégorie, avec le podium signalé, l’écart au premier et l’ordre de tri annoncé. Ajoute la composition « Tableau de classement triable » à 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-resultats-classement
*Free component: copy it freely, including for commercial projects.
Other data tables components in WordPress
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

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

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

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

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

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