Jump to content

Clickable phone number and mail in PHP


Raf

Recommended Posts

Hello. I need to add clickable phone number and mail. I learn html and js, so.... ;)

Can You help?

<?php if(!empty($header_email)): ?> 
  <li>
    <span><i class="fa <?php echo esc_attr($header_email_icon);?>"></i></span> 
       <?php echo esc_html($header_email);?>
  </li> 
       <?php endif; ?> <?php if(!empty($header_phone)): ?> 

<li>
   <span><i class="fa <?php echo esc_attr($header_phone_icon);?>"></i></span>
  
     <?php echo esc_html($header_phone);?></li> <?php endif; ?>

I added the code, but It dosen't work.

 

<a href="<?=$header_phone?>"><?=$header_phone?></a> 

Can You help?

Regards and thank You

Link to comment
Share on other sites

I think that I replicated your code.  

if(!empty($header_email))
{
	$icon = esc_attr($header_email_icon);
	echo "<li>
			<span>
			<i class='fa $icon'></i>
			</span>";
	echo esc_html($header_email);
	echo "</li>";
}
if(!empty($header_phone))
{ 
	$ph = esc_attr($header_phone_icon);
	echo "<li>
		<span>
		<i class='fa $ph'></i>
		</span>";
	echo esc_html($header_phone)
	echo "</li>";
}
echo "<a href='$header_phone'>$header_phone</a>"; 

A bit cleaner to read now.   That said I don't know what your anchor is supposed to do with that phone number.  It should be some destination rather than a simple phone number, no?  And how do you have a separate class for each phone or email value?  That space you placed after 'fa' implies a separate classname so I am confused.

OK - had to correct the code I tried to replicate.  You have some huge issues here.  You have a list item that I think you want to show in italics but also using a strange class.  I don't think the class is being specified correctly and there is nothing inside the (outdated) italics tag to be shown. 

Edited by ginerjm
Removed code for correcting.
Link to comment
Share on other sites

Hello,

Well, the code should do the same like this:

<a href="tel:123">123</a>
<a href="mailto:123@gmail.com">123@gmail.com</a>

nothing more.

I found it, I consulted with the support, confirmed the correctness of my assumption;) unfortunately, they do not support such changes, (hm) and I want to add a simple in my understanding functionality, clickable phone and mail. I don’t know if their code is correct, I don’t judge it. Is this code above working, tested?

Regards

Raf

Edited by Raf
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.