and like us on FB

Your website should do everything it can to make the user experience a pleasurable one, and to reduce the barriers necessary for a user to convert as you want them to. In essence, the former consideration is a key component to the latter objective. A small but effective change to your contact link will draw you closer towards meeting both those aims. While a contact form is still a necessity on both mobile and desktop applications, you can add an additional link for mobile users to launch a telephone call. It’s this feature that is discussed in brief on this page (with supporting WordPress shortcode).

In our case, we have a small telephone icon at the bottom of every page that renders a link based on the platform the visitor is using; either a link to our contact page or a call link. We use WordPress’ largely flawed wp_is_mobile() function to determine the platform, and then display an icon.

Contact BeliefMedia

The icon above demonstrates the end result.

You may optionally wrap text in telephone shortcode tags to return a text link. The shortcode of [telephone]call me[/telephone] returns call me. Note: The shortcode parser is unable to handle mixing of enclosing and non-enclosing forms of the same [$tag]. You should use one or the other (inside the loop). If you do require a mix of text and image links on the same page, close all shortcodes.

Tel: Schema

In addition to the tel: schema, some modern browsers also support the sms: and mms: schemas (all supported in our code) – though support is not as consistent, and some features like setting the message body don’t always work. In its simplest form, the schema for a mobile link is as follows.

<a href="tel:+61400777300">link</a>

Note that we’ve started the phone number with a + sign. The country code and area codes should follow. So, always use the international calling format.

WordPress Shortcode

Copy and paste the WordPress function into your theme's functions.php file or, if you sensibly have one installed, your custom functions plugin. You may optionally download and install our plugin from the bottom of of the page.

If you require shortcode to work in a sidebar widget, you'll have to enable the functionality with a filter. If you're using our custom functions plugin, you'll have that feature enabled by default.

Shortcode Attributes

Alter the attributes to reflect your default behaviour. That said, you can alter the behavior with the following:

type

Permitted schema types include tel, sms, and mms. The message option was left out simply because it’s largely unsupported.

tel

The full the international calling format of a telephone number.

image

The image to display.

link

The image link.

title

The image title attribute.

style

Style applies to the alignment of the image. If using inline, you may have to alter it to center it with text.

WordPress Plugin

If you download our plugin below, you’ll have a control panel option to update your default settings.

Telephone Call HTML Link (and WordPress Shortcode)

PHP Function

If you choose to use the feature outside of WordPress, use the beliefmedia_wp_is_mobile() from this page (it’s a copy of the WP function). The function is included in the download below.

Other than the telephone number and schema type, other arguments are (optionally) passed via the $args array. Alter the $atts array to reflect your own defaults.

Considerations

  • The tel URI for Telephone Numbers on ietf.org .
  • URI tel schema on schema.org .
  • To prevent Mobile Safari from automatically detecting phone numbers, add the following meta tag to the top of the page: <meta name="format-detection" content="telephone=no">.
  • While not absolutely necessary, it’s a good idea to separate each segment of the number with a hyphen (-) for easier reading and better auto-detection.

Download

Title: Telephone Call HTML Link (and WordPress Shortcode)
Description: Renders a telephone image link or text link with shortcode.
Download: Shortcode (V0.1) | WP Plugin (V0.1) | PHP Code (V0.1)

Shortt URL for this post: http://shor.tt/B5f