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;
}

Streamline Your Clickable Links with Ease!

Transform your Divi site with seamless link enhancements using the Divi Booster plugin. Effortlessly add and customize clickable links like 'Click to SMS' in your top header, saving you time and enhancing user interaction. Get ready to boost your site functionality with hundreds of features!

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.