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 From Divi Booster

Enable Automatic Looping for YouTube Videos in the Divi Video Module

Enabling automatic looping for YouTube videos in your Divi video module ensures that content plays seamlessly and continuously without interruption. This feature can enhance user engagement, highlight key information, or create dynamic visual effects on your website....

Hide Video Controls in Divi Video Module

Disabling YouTube video controls in the Divi Video Module helps create a seamless, distraction-free viewing experience for your site visitors. This approach is useful when you want full control over how your video content appears and is interacted with on the page, or...

Mute YouTube Videos by Default in the Divi Video Module

In the Divi Video Module, starting your YouTube videos muted by default can create a more user-friendly browsing experience on your webpage. It is particularly beneficial for reducing distractions, enhancing visitor engagement, and providing a seamless content preview...

Autoplay Videos in Divi Video Module

Enabling videos in your Divi video module to start playing automatically can enhance both the site's design and user engagement. To ensure full compatibility with browser requirements, such as Chrome's autoplay policy, it's often necessary to start your videos muted...

How to Add the Post Status in Divi's Dynamic Content

Divi's Dynamic Content feature is great for enhancing your post/page templates with post-specific information. While Divi includes an option to show information such as the Post Created Date using Dynamic Content, there is no equivalent option for the Post Status....

Random Divi Posts