Divi tip – Add link to phone number in top header

Divi tip – Add link to phone number in top header

Surprisingly, the phone number input on the top header is not linkable in Divi.

The reason is because it is ‘sanitized’ on output. So whatever you add to that field, it’s all stripped out before its displayed on the frontend.

The reasoning is because… Elegant Themes thought it was a good idea. I don’t agree, but I don’t disagree either. Sometimes it’s safe to sanitize those fields. So yeah, whatevs.

 

Anyways, let’s change that.

You’re gonna have to edit the header, so you’ll need a child theme. Get one here (Click me).

Inside that child theme, you’ll see header.php

Open it up.

Change line 65 to this:

<span id="et-info-phone"><a href="<?php echo esc_attr( 'tel:' .$et_phone_number); ?>"><?php echo et_core_esc_previously( et_sanitize_html_input_text( $et_phone_number ) ); ?></a></span>

Done.

Now you’ll get the phone number to link directly to the number. It’s pretty helpful on mobile devices.

 

[sc name=”responsive-ad”]

 

[gravityform id=”1″ title=”False”]

 

Photo by Anastasia Dulgier on Unsplash

Why no ads?

Hi, my name is PK, and welcome to my website, almost inevitable design. I maintain and publish on this site for two reasons.

  1. To give back to the community. I learned so much from people's tutorials and StackOverflow that I wanted to contribute and help others.
  2. To provide a more structured learning experience. People struggle to find the course that guides them from start to finish, based off of real life experience, and my courses provide that.

The only "ads" I have here are for my own courses, and maybe an affiliate link, but that's it. They fund the website resources and provide more motivation for me to product better content.

Any bit of interest helps. Even sharing with your feidns, suggesting my courses to your developer or designer, or subscribing to my YT channel, or joining our Discord. Thanks and I'll see you around!

The Web Design Space

TWDS is my web design agency. If you're looking for premium quality, reliable, web design and development, come see what we're about!
Learn More
Choose "Paythen" at checkout for an interest free 10 week payment plan.
Leave a Reply

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

  1. Or just input CALL ME to Header Element Menu in custum DIVI theme

    • Hmmm… although you could do that, it’s a lateral approach, and this post was about changing the behavior of the top header. Thanks for your idea though, I’m sure it’ll be a good alternative suggestion for anyone looking to do that.

      • Yes, but this avoids modifying the parent theme files. I try as much as possible not to modify the parent files for the future update ;-)

        • You don’t have to edit the parent theme if you’re using a child theme, which you always should.

New tutorials