Home Forums General Issues Output email field to include mailto: with email


Output email field to include mailto: with email

  • I’m using a block that can dynamically display data from ACF fields, one issue is if I have a button link with an email it doesn’t include mailto: so clicking the email doesn’t work correctly. Is there any way I can force ACF to output mailto: before the email address on an email field?

  • I would need more information to be sure, like what is the HTML that is actually being created and how it is generated.

    Without his information what I would say is to add an acf/format_value filter that prepends “mailto:” to the value that acf is returning.

  • Thanks yes a mailto: prepend would do this.
    So it would look something like this?

    add_filter(‘acf/format_value/type=email’, “mailto:”, 10, 3);

    add_filter('acf/format_value/type=email', 'prepend_mailto', 20);
    function prepend_mailto($value) {
      $value = 'mailto:'.$value;
      return $value;
  • Thanks that did the trick

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.