Skip to content

Accordion FAQ in WordPress

Questions that expand one by one, with FAQPage structured data for Google.

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

faq-accordeon-simple.php
<?php
/**
 * Plugin Name: Forge, FAQ en accordéon
 * Description: Des questions dépliables une à une, avec les données structurées FAQPage pour Google. Ajoute la composition « FAQ en accordéon » à 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-faq-accordeon-simple
 *
pattern.html
<!-- wp:group {"tagName": "section", "className": "faq", "layout": {"type": "default"}} -->
<section class="wp-block-group faq"><!-- wp:heading {"level": 2} -->
<h2 class="wp-block-heading">Questions fréquentes</h2>
<!-- /wp:heading -->
<!-- wp:details -->
<details class="wp-block-details"><summary>Intervenez-vous le week-end ?<span class="faq__icon"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 2v12M2 8h12"/></svg></span></summary><!-- wp:paragraph -->
<p>Oui, pour les urgences (fuite, panne de chauffage), nous intervenons le samedi et le dimanche avec une majoration de 30 % annoncée avant le déplacement.</p>
<!-- /wp:paragraph --></details>
<!-- /wp:details -->
<!-- wp:details -->
<details class="wp-block-details"><summary>Le devis est-il gratuit ?<span class="faq__icon"><svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 2v12M2 8h12"/></svg></span></summary><!-- wp:paragraph -->
<p>Oui. Nous nous déplaçons gratuitement dans un rayon de 25 km pour établir un devis détaillé, valable trois mois.</p>
style.css
:root {
  --faq-bg: #ffffff;
  --faq-line: #dbe3ee;
  --faq-text: #0f172a;
  --faq-muted: #475569;
  --faq-accent: #1d4ed8;
  --faq-ring: #1d4ed8;
  --demo-faq-accordeon-simple-bg: #f4f7fb;
  --demo-faq-accordeon-simple-text: #0f172a;
}

@media (prefers-color-scheme: dark) {

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

FAQ and accordions components in WordPress
  • A native accordion FAQ where each answer asks “Was this answer helpful?”, with a thank-you message and a remembered vote.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • An introduction and a contact link on the left, expandable questions on the right.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A tight accordion within a single frame, for practical information pages.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • Questions grouped under subheadings, for long FAQs.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • All answers visible at once, presented as a card grid.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • Frequently asked questions followed by a card inviting visitors to call or write.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component