How to Add a WhatsApp Button to WordPress Without a Plugin

Plugins for WhatsApp buttons are bloated. They load 30 KB of CSS, track your visitors, and break with theme updates. The whole thing is six lines of HTML and a wa.me link. Here’s the copy-paste version that works on any WordPress theme.

Step 1: get your WhatsApp link

Use the WhatsApp link generator to build the link with a prefilled message:

https://wa.me/14155552671?text=Hi%2C%20I%20saw%20your%20website

Replace the number with your WhatsApp Business number (full international format, no plus sign, no zeros).

Step 2: pick where the button goes

Three common patterns:

  • Floating bottom-right corner. Most visible, slightly aggressive.
  • Header CTA. Less intrusive, fits with site navigation.
  • Inline (in posts or contact page). Contextual, lower friction.

Floating button: full HTML and CSS

Add this to your theme’s footer (Appearance → Theme File Editor → footer.php), or use a code-injection plugin like Insert Headers and Footers if you’re not comfortable editing PHP:

<a href="https://wa.me/14155552671?text=Hi"
   class="wa-float"
   target="_blank"
   rel="noopener"
   aria-label="Chat on WhatsApp">
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="28" height="28" fill="white">
    <path d="M16.003 2.668c-7.358 0-13.335 5.977-13.335 13.335 0 2.353.617 4.654 1.79 6.683l-1.902 6.946 7.108-1.866c1.957 1.067 4.158 1.628 6.339 1.628h.005c7.358 0 13.335-5.977 13.335-13.391 0-3.563-1.385-6.91-3.902-9.428a13.328 13.328 0 0 0-9.438-3.907zm0 24.448a11.083 11.083 0 0 1-5.654-1.546l-.405-.241-4.205 1.103 1.124-4.099-.265-.42a11.073 11.073 0 0 1-1.696-5.91c0-6.122 4.98-11.103 11.103-11.103 2.965 0 5.751 1.156 7.847 3.255 2.099 2.099 3.255 4.886 3.252 7.853 0 6.124-4.98 11.108-11.101 11.108z"/>
  </svg>
</a>

Then add the CSS to your theme’s stylesheet (Appearance → Customize → Additional CSS):

.wa-float {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  background: #25D366;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  transition: transform 0.2s;
}
.wa-float:hover {
  transform: scale(1.1);
}

That’s the entire button. ~1 KB of code, zero JavaScript, no plugins.

Inline button (post or page)

For an inline CTA inside a post, switch the WordPress block editor to “Custom HTML” and drop in:

<a href="https://wa.me/14155552671?text=Hi"
   target="_blank"
   rel="noopener"
   style="display: inline-block; padding: 12px 24px; background: #25D366; color: white; border-radius: 8px; text-decoration: none; font-weight: 600;">
  Message us on WhatsApp
</a>

Inline styles for one-off use are fine. For repeated use, define a CSS class.

Show on specific pages only

If you want the floating button only on certain pages (e.g., not the homepage), wrap the HTML in a PHP conditional inside footer.php:

<?php if (is_singular('post') || is_page('contact')) : ?>
  <!-- Your WhatsApp button HTML -->
<?php endif; ?>

Track clicks

Two simple options:

Google Tag Manager

Create a click trigger that fires on links matching wa.me. Send an event to Google Analytics. No code changes needed.

Direct gtag

Add an onclick handler:

<a href="https://wa.me/..." onclick="gtag('event', 'whatsapp_click');">

Mobile considerations

The floating button looks fine on mobile but eats screen real estate over scrolling content. Two options:

  • Smaller button on mobile. Add a media query that drops it to 48 px on screens under 600 px wide.
  • Hide while scrolling. A small JS snippet that hides the button on scroll-down and shows on scroll-up. ~10 lines of code.

Common mistakes

  • Including a + before the number in the wa.me URL. Drop it.
  • Forgetting target="_blank" and rel="noopener". WhatsApp Web should open in a new tab on desktop.
  • Stacking the button with another floating element. Coordinate with chat widgets or cookie banners — set a high z-index but check for overlap.
  • Forgetting the prefilled message. An empty chat is friction. Even a simple “Hi” makes it easier for visitors to start.

Why skip the plugin?

PluginHand-coded
File size20-50 KB~1 KB
Render-blocking JSOftenNone
Tracking your visitorsMany doYou control it
Theme update breakagePossibleStable
CustomizationPlugin-limitedTotal

FAQ

Will this work with Elementor or Divi?

Yes. Add the HTML through a Custom HTML widget. The CSS goes in the theme’s customizer or the page builder’s custom CSS panel.

Does this slow down the site?

No. It’s a static SVG and a few lines of CSS — no scripts, no external requests.

Will the button show on AMP pages?

You’d need an AMP-compatible version (no inline styles, validated structure). For most non-AMP WordPress sites, the regular version works fine.

Can I use a custom icon instead of the SVG?

Yes. Swap the <svg> for an <img> tag with your icon URL. Keep dimensions at 28-32 px for the floating button.

Should I use WhatsApp or WhatsApp Business?

Business. Free, looks professional in chat, supports auto-replies and labels. Don’t use your personal number.

Generate your link, drop it in

Build the link with the WhatsApp link generator (it handles message encoding for you), paste it into the HTML above, save. Pair with a click-to-call button if your audience splits between voice and text.