Add a "Click to SMS" Link to Divi Top Header

Written by Dan Mossop

I've previously written about how to make the Divi header phone number into a clickable link. But what if you want to be able to trigger an SMS instead?

Unfortunately, the technique described in that post won't work as Divi strips the SMS protocol from links added via the phone number field.

We can instead add a new link alongside the phone / email links, using the following JavaScript code:

<script>
jQuery(function($){
	if (!$('#et-info').length) {
		$('#top-header > .container').prepend('<div id="et-info"></div>');
	}
	$('#et-info').prepend('<a class="et-info-sms" href="sms://+6112341234">SMS me</a>');
});
</script>
See this post for more info on the format of SMS links.

You may also wish to add an icon to your SMS link, a speech bubble icon for example. You can do that with the following CSS:

.et-info-sms:before { 
	content: '>';
	font-family: 'ETModules';
    margin-right: 4px;
}

Supercharge Engagement with AI-Driven CTAs

Transform every post on your WordPress site with WP Magic CTAs. This AI-powered plugin generates precise, irresistible calls-to-action for each article, boosting interaction and conversion rates. Perfect for highlighting offers, expanding your email list, or directing visitors where they're needed most.

About Dan Mossop

Dan is a Scottish-born web developer, now living in Brisbane with his wife and son. He has been sharing tips and helping users with Divi since 2014. He created Divi Booster, the first Divi plugin, and continues to develop it along with 20+ other Divi plugins. Dan has a PhD in Computer Science, a background in web security and likes a lot of stuff, 

2 Comments

  1. I've tried to do this and nothing is popping up in the top header. Am I missing something? Was there an update that made this not work? Any help would be greatly appreciated.

    Reply
    • Hi Tony, it looks like the code is still working in the latest Divi. There are a few reasons why it might not show.

      One is if you aren't including a phone number / email alongside it. The original code relies on the existence of an HTML element that is added when a phone number / email is used. I've just updated the code so that it will add the element if not already present. This means that you should be able to use the SMS link without needing the phone / email to be present.

      Another is caching – if you haven't already, try clearing the caches in any performance plugins you're running, then clear your browser cache to ensure you're seeing the latest version of the page.

      If that doesn't help, perhaps you can send me a link to the site you're working o so that I can take a look?

      Thanks!

      Reply

Submit a Comment

Comments are manually moderated and approved at the time they are answered. A preview is shown while pending but may disappear if your are cookies cleared - don't worry though, the comment is still in the queue.

Your email address will not be published. Required fields are marked *.

We may earn a commission when you visit links on our website.

Latest Posts

Set Custom CSS IDs for Individual Divi Accordion Items

Assigning unique CSS IDs to specific Divi Accordion items allows for precise control over styling, targeting, and linking within your page content. This ability is particularly useful when you want to apply custom designs or create anchor links to particular accordion...

Enable Swipe Navigation in the Divi Gallery Lightbox

Enabling swipe navigation in the Divi Gallery module's lightbox allows users to seamlessly browse through gallery images by swiping left or right, creating a more interactive and mobile-friendly experience. This functionality can significantly improve user engagement...

Disable Slide-In Animation for Divi Gallery Grid Images

Control how images appear in your Divi Gallery module by toggling the slide-in animation effect for grid layouts. Disabling the slide-in animation allows gallery images to load instantly and appear statically, providing a faster and distraction-free browsing...

Control Image Count Display in Divi Gallery Lightbox

Displaying or hiding the image count in the Divi Gallery module’s lightbox can help customize the user experience, depending on whether you want to give visitors an indication of gallery progress or prefer a cleaner, distraction-free view. The ability to toggle this...

Hide Gallery Image Titles in the Divi Lightbox Overlay

Displaying image titles in the lightbox overlay of the Divi Gallery module can sometimes be distracting or unnecessary, depending on your website’s design and user experience goals. Hiding these titles creates a cleaner and more focused viewing experience for visitors...

Random Posts