Skip to content

Customer reviews with overall rating in WordPress

A reviews section for local shops: average star rating out of 5, a star breakdown that animates into view and the three latest reviews signed with a first name and a town.

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 -->
<section class="avce" aria-labelledby="avce-title" data-avce>
        <div class="avce__head">
          <p class="avce__eyebrow">Avis clients</p>
          <h2 class="avce__title" id="avce-title">Ce que nos clients disent de la Boulangerie Perrin</h2>
        </div>
        <div class="avce__summary">
          <div class="avce__score">
            <p class="avce__value">4,7<span class="avce__out"> / 5</span></p>
            <span class="avce__stars" role="img" aria-label="Note moyenne : 4,7 sur 5"><svg class="avce__stars-base" viewBox="0 0 120 24" width="120" height="24" aria-hidden="true"><path transform="translate(0 0)" d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3l-5.9 3.3 1.3-6.6-4.9-4.6 6.6-.8z"/><path transform="translate(24 0)" d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3l-5.9 3.3 1.3-6.6-4.9-4.6 6.6-.8z"/><path transform="translate(48 0)" d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3l-5.9 3.3 1.3-6.6-4.9-4.6 6.6-.8z"/><path transform="translate(72 0)" d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3l-5.9 3.3 1.3-6.6-4.9-4.6 6.6-.8z"/><path transform="translate(96 0)" d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3l-5.9 3.3 1.3-6.6-4.9-4.6 6.6-.8z"/></svg><span class="avce__stars-fill" style="width: 94%"><svg class="avce__stars-on" viewBox="0 0 120 24" width="120" height="24" aria-hidden="true"><path transform="translate(0 0)" d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3l-5.9 3.3 1.3-6.6-4.9-4.6 6.6-.8z"/><path transform="translate(24 0)" d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3l-5.9 3.3 1.3-6.6-4.9-4.6 6.6-.8z"/><path transform="translate(48 0)" d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3l-5.9 3.3 1.3-6.6-4.9-4.6 6.6-.8z"/><path transform="translate(72 0)" d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3l-5.9 3.3 1.3-6.6-4.9-4.6 6.6-.8z"/><path transform="translate(96 0)" d="M12 2.5l2.9 6.1 6.6.8-4.9 4.6 1.3 6.6L12 17.3l-5.9 3.3 1.3-6.6-4.9-4.6 6.6-.8z"/></svg></span></span>
            <p class="avce__count">212 avis, dont 94 % à 4 ou 5 étoiles</p>
          </div>
script.js
(() => {
  if (!document.querySelector(".avce")) return;
  document.querySelectorAll("[data-avce]").forEach((root) => {
    root.querySelectorAll("[data-avce-read]").forEach((button) => {
      const rest = document.getElementById(button.getAttribute("aria-controls"));
      const dots = button.parentElement.querySelector("[data-avce-dots]");
      rest.hidden = true;
      dots.hidden = false;
      button.hidden = false;
      button.addEventListener("click", () => {
        const open = button.getAttribute("aria-expanded") !== "true";
        button.setAttribute("aria-expanded", String(open));
style.css
:root {
  --avce-text: #1c1917;
  --avce-muted: #57534e;
  --avce-card: #ffffff;
  --avce-soft: #fff7ed;
  --avce-line: #e7e5e4;
  --avce-border: #d6d3d1;
  --avce-track: #e7e5e4;
  --avce-star: #b45309;
  --avce-star-off: #d6d3d1;
  --avce-accent: #9a3412;
  --avce-accent-hover: #7c2d12;
temoignages-avis-clients-etoiles.php
<?php
/**
 * Plugin Name: Forge, Avis clients avec note globale
 * Description: Une section d'avis pour commerce de proximité : note moyenne sur 5 en étoiles, répartition par étoiles animée à l'apparition et les trois derniers avis signés d'un prénom et d'une ville. Ajoute la composition « Avis clients avec note globale » à 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-temoignages-avis-clients-etoiles
 *

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

Testimonials components in WordPress
  • A customer reviews section with average rating and star distribution; each bar is a button that filters the reviews with that rating.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A CSS-drawn video poster with a play button, the testimonial's key quote, its author, and the timestamped transcript in a collapsible panel.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • Three customer reviews as cards, with star rating and customer tenure.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A row of client references as wordmarks, followed by a representative quote.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A single highlighted quote, with the name and role of its author.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component