WordPress.org

Forums

[resolved] Using wp_is_mobile to display clickable number for mobile users (2 posts)

  1. matthewpolld
    Member
    Posted 1 year ago #

    I am trying to display a html5 clickable phone number only for mobile websites. When the site is being viewed on desktop, I want to display the phone number just as text, not something that can be clicked on and rung. My code doesn't seem to be working:

    if ( $phone ) {
        if ( wp_is_mobile() ) {
        echo  "<a href='tel:$phone'  >$phone</a><br />";
        }else{
        echo '
        <div class="widget-textarea">' . $phone . ' </div> ';
         }
     }

    The number displays as just text when viewed on a desktop, but the clickable html5 phone number for mobile, doesn't display as clickable.

    Any advice, please? Is this the best way of achieving this?

  2. matthewpolld
    Member
    Posted 1 year ago #

    After testing it again, I'm mistaken, it works!

Topic Closed

This topic has been closed to new replies.

About this Topic