WordPress.org

Ready to get started?Download WordPress

Forums

[closed] using tel: links in wp_nav_menu (9 posts)

  1. davidpmccormick
    Member
    Posted 2 years ago #

    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

  2. davidpmccormick
    Member
    Posted 2 years ago #

    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');
    });
  3. Tevya
    Member
    Posted 2 years ago #

    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.

  4. meeble
    Member
    Posted 2 years ago #

    @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>
  5. meeble
    Member
    Posted 2 years ago #

    actually, this is my code:

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

    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.

  7. Tevya
    Member
    Posted 1 year ago #

    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?

  8. quinlo
    Member
    Posted 1 year ago #

    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.

  9. Andrew
    Forum Moderator
    Posted 1 year ago #

    Try the Requests and Feedback forum for this suggestion.

Topic Closed

This topic has been closed to new replies.

About this Topic