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

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....

Fix Divi Text Module "Regular" Font Weight Not Working

Are you encountering an issue where the font weights in Divi's Text Module don't seem to apply as expected? In particular, you might find that when you set the text module's body text font weight to "Regular", your font is actually assigned a weight of 500 instead of...

Make the Divi Gallery Module Swipeable

The Divi Gallery Module comes with a slider mode that lets you display images in a slider with clickable left/right arrows to scroll through the images. For mobile / touchscreen users, you can improve the user experience by allowing your user to swipe to navigate to...

How to Use Divi Dynamic Content in Woo Modules Product Selector

Divi's Dynamic Content is a powerful feature that lets you populate your Divi modules and theme builder templates with data pulled in various sources, such as custom fields. This allows for efficient organization and maintenance of your sites.Unfortunately, Divi's...

Random Divi Posts