1

Can someone explain how I would rewrite this bit of code to include a tel: clickable phone number and make the email address clickable to info:hi.com

I am having a bit of trouble with this.

<address class="address_phone">
                                        <span class="icon icon-phone"></span>
                                        <div class="contact_title"><?php echo esc_html__('Phone:', 'yogastudio') ?></div>
                                        <span class="contact_item phone"><?php if (!empty($phone)) echo esc_html($phone); ?></span>
                                        </address></div><div class="column-1_3">
                                    <address class="address_email">
                                        <span class="icon icon-mail"></span>
                                        <div class="contact_title"><?php echo esc_html__('Email:', 'yogastudio') ?></div>
                                        <span class="contact_item mail"><?php if (!empty($email)) echo esc_html($email); ?></span>

                                    </address></div>
0

Please edit your code as below:

<address class="address_phone">
                                        <span class="icon icon-phone"></span>
                                        <div class="contact_title"><?php echo esc_html__('Phone:', 'yogastudio') ?></div>
                                        <span class="contact_item phone">
                                            <?php if (!empty($phone)) { echo '<a href="tel:'.$phone.'">'.esc_html($phone).'</a>';} ?>
                                        </span>
                                        </address></div><div class="column-1_3">
                                    <address class="address_email">
                                        <span class="icon icon-mail"></span>
                                        <div class="contact_title"><?php echo esc_html__('Email:', 'yogastudio') ?></div>
                                        <span class="contact_item mail"><?php if (!empty($email)) { echo '<a href="mailto:'.$email.'">'.esc_html($email).'</a>';}?></span>

                                    </address></div>
  • 1
    Can you edit your question to explain how this solves the problem? If the OP ever has to add another tel: to their footer they would need to pick apart your code example to figure out what you did – Tom J Nowell Aug 30 at 14:05
  • yes that worked great thanks. I have another corresponding tel and email in the top panel of the theme which i can't seem to find the code for. Does work though – user3504751 Aug 30 at 14:22
1

Remove.

<?php if (!empty($phone)) { echo '<a href="tel:'.$phone.'">'.esc_html($phone).'</a>';} ?>

Replace with

<a href="tel:+4401234567895">Call us</a>

Note you should include the International dial code as well.

For the email, replace

<?php if (!empty($email)) { echo '<a href="mailto:'.$email.'">'.esc_html($email).'</a>';}?>

With:

<a href="mailto:youremail@yourdomain.com">Email us</a>
  • This reads more like an extended comment on @Praktib.Simform's answer than an answer in its own right. Please edit the answer to answer the original question more fully. – Pat J Aug 30 at 14:19
  • @PatJ I think this is just a better version of that answer as it's easier to see what the solution is, whereas the other answer is just copy pasta that doesn't explain anything – Tom J Nowell Aug 30 at 16:48
  • I agree, it definitely has better explanations; its advice to "Replace X with Y", though, references X from the other answer, not from the question. (Which, I realize, is kind of nitpicky, but if the other answer gets modified or removed this answer no longer really applies.) – Pat J Aug 30 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.