Reputation: 11
I tried everything to make the phone number clickable but for some reason it didn't work
<?php global $redux_demo;?>
<?php $phoneon= $redux_demo['phoneon']; ?>
<?php if($phoneon == 1){?>
<?php $post_phone = get_post_meta($post->ID, 'post_phone', true); ?>
<?php if(!empty($post_phone)) {?>
<li><span><?php esc_html_e( 'Phone', 'classiera' ); ?></span><?php echo $post_phone; ?></li>
I added this and it still didn't work :
<a href="tel:$post_phone"> $post_phone</a>
and this
<li><span><?php esc_html_e( 'Phone', 'classiera' ); ?></span><a href="callto://<?php echo $post_phone; ?>"><?php echo $post_phone; ?></a></li>
<?php }?>
Thank you so much for your help
Upvotes: 1
Views: 239
Reputation: 123
If it is not working for you in PHP write it in HTML
<a href="tel:003531234567">Call me</a>
If that doesnt work it is probably something to do with the phone nummber, make sure it is set up for international calling.
Upvotes: 0
Reputation: 393
If your php version is greater then 5.4, then you can write it as
<a href="tel:<?== $post_phone; ?>"><?= $post_phone; ?></a>
To check PHP version
<?php phpinfo(); ?>
Upvotes: 0
Reputation: 151
Easier to do it all in PHP:
<?php
echo '<a href="tel:' . $post_phone . '">' . $post_phone . '</a>';
echo '<li><span>' . esc_html_e( 'Phone', 'classiera' ) . '</span><a href="callto://' . $post_phone . '">' . $post_phone . '</a>'
?>
Upvotes: 0
Reputation: 16074
This should work
<a href="tel:<?php echo $post_phone; ?>"><?php echo $post_phone; ?></a>
Upvotes: 1