Skip to content

Call-now button with a clickable number in WordPress

A desktop contact card with a clickable tel: number, a live Available badge and response hours, for tradespeople who want to be phoned directly.

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

bouton-appeler-maintenant-fixe-bureau.php
<?php
/**
 * Plugin Name: Forge, Bouton « Appeler maintenant » avec numéro cliquable
 * Description: Une carte de contact pour ordinateur avec le numéro cliquable (lien tel:), une pastille « Disponible » calculée en direct et les horaires de réponse, pour les artisans qui veulent être appelés. Ajoute la composition « Bouton « Appeler maintenant » avec numéro cliquable » à 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-bouton-appeler-maintenant-fixe-bureau
 *
pattern.html
<!-- wp:html -->
<section class="apm" aria-labelledby="apm-titre" data-apm data-apm-hours="[[],[[450,1140]],[[450,1140]],[[450,1140]],[[450,1140]],[[450,1140]],[[480,720]]]">
        <div class="apm__main">
          <div class="apm__head">
            <span class="apm__avatar" aria-hidden="true">JM</span>
            <div class="apm__who">
              <p class="apm__name">Julien Morel</p>
              <p class="apm__role">Électricien à Nantes, certifié Qualifelec</p>
              <p class="apm__status" data-apm-status hidden><span class="apm__dot" aria-hidden="true"><span class="apm__ping"></span></span><span data-apm-status-text></span></p>
            </div>
          </div>
          <h2 class="apm__title" id="apm-titre">Un projet ou une panne ? Appelez-moi directement</h2>
script.js
(() => {
  if (!document.querySelector(".apm")) return;
  const DAYS = ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"];

  function apmTime(minutes) {
    const m = minutes % 60;
    return `${Math.floor(minutes / 60)} h${m ? ` ${String(m).padStart(2, "0")}` : ""}`;
  }

  // Works out whether the line is answered now and, if not, when it is answered again (up to a week ahead).
  function apmStatus(hours, now) {
    const day = now.getDay();
style.css
:root {
  --apm-text: #1c1917;
  --apm-body: #44403c;
  --apm-line: #e7e5e4;
  --apm-surface: #ffffff;
  --apm-aside: #faf7f2;
  --apm-shadow: 0 18px 40px -24px rgb(28 25 23 / 0.35);
  --apm-accent: #c2410c;
  --apm-call-bg: #c2410c;
  --apm-call-hover: #9a3412;
  --apm-call-text: #ffffff;
  --apm-copy-border: #d6d3d1;

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

Calls to action components in WordPress
  • A promotional card for a course, a workshop or an opening: remaining seats, a fill bar, the registration deadline and a booking button, with no countdown timer.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A Free quote within 24 hours banner with a request button, a clickable phone number and three guarantees (no commitment, fast reply, free visit), with no JavaScript.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A call to action for a limited offer: serif heading, two links and a countdown in days, hours and minutes inside a coupon-style frame.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A direct-call block for emergencies, with the number in very large type and response times.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A sign-up box with an email field, a button and a note on how the address is used.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A full-width band with a heading, a sentence and two action buttons.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component