WordPress.org

Support

Support » How-To and Troubleshooting » using tel: links in wp_nav_menu

using tel: links in wp_nav_menu

  • Hi,

    iOS recognises links in the format <a href="tel:07954000000">CALL<a/>

    I’d like to add such a link as a ‘Custom Link’ to a wp_nav_menu that I’m only targeting at iOS (more specifically, only iPhones) but entering “tel:07954000000” in the URL amounts to nothing (it gets wiped when I try to save the menu).

    I suppose these links have to start “http://” (or similar) to work; I wonder if anyone knows of a way in which I could make this work (short of hard coding it in).

    Basically, I’d like a link on my wp_nav_menu which, when tapped, will make a phone call.

    All suggestions much appreciated.

    Thanks,
    D

Viewing 8 replies - 1 through 8 (of 8 total)
  • I’ve found a solution.

    I set up the Custom Link with a url that WordPress accepts (eg http://changethisonload.com) and give the menu item a class (eg ‘changeonload’), then use jquery to target the anchor tag in the ‘changeonload’ classed list item:

    $(document).ready(function(){
        $('.changeonload a').attr('href','tel: 07954000000');
    });

    Seems strange that WP wouldn’t support those kinds of links… I’d like to do this as well, but I’m no programmer like yourself. I wonder if they’d add it in a future version of WP if it was reported as a bug or something. I just checked and a mailto:email@here.com doesn’t get stripped out like a tel:07954000000 one does. So you can put an email link right in a menu, strange that you can’t put a telephone link.

    @davidpmccormick,

    Is there any specific way to include/insert that javascript code to make it work correctly? I tried doing something like this which didn’t work:

    <script language="javascript" type="text/javascript">
    <!--
    $(document).ready(function(){
        $('.far-right a').attr('href','tel:602-315-0000');
    });
    -->
    </script>

    actually, this is my code:

    <script language="javascript" type="text/javascript">
    <!--
    $(document).ready(function(){
        $('.far-right a').attr('href','tel:602-315-0000');
    });
    //-->
    </script>

    So… I know this may be out of date… but searching these forums helps me… and maybe this response will help someone someday…

    Check out: http://core.trac.wordpress.org/ticket/18268

    You need to edit the file ‘formatting.php’ located in wp-includes according to the patch found at the aforementioned URL. It works like a charm.

    Is formatting.php part of the WP core? If so, could this be put into a plugin, so it doesn’t get overwritten with updates?

    It’d be great if someone fashioned a plugin for this. It would be even better if WP just incorporated more protocols to be allowed for custom links in the menu.

    Try the Requests and Feedback forum for this suggestion.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘using tel: links in wp_nav_menu’ is closed to new replies.
Skip to toolbar