Home Forums General Issues Add a subject line to Email mailto?


Add a subject line to Email mailto?

  • So I am building a profile page template in Elementor that dynamically pulls content from ACF fields. I have it pulling the email field into a clickable mailto link which is working great but I’m just wondering if there’s a way to add a set subject line to the field as well?


    However, I should warn you that this is old. You can add a subject and even body content if you do a search for that, but having them may trigger a security warning in some browsers now. Doing this is frowned upon.

  • Aha thank you for the info!

  • I’m very late to this thread, but @sebarts I’d love to know how you made a clickable mailto link with ACF. I’m scouring the web and no one seems to have a good answer.

    I have tried:
    Creating a URL field and putting in the mailto: link there (doesn’t work, ACF says that it’s not a valid URL)
    Creating a Link field and putting the mailto: link there, which ACF accepts, but then that field doesn’t show up as an option when I’m trying to create a template to draw dynamic content.

  • I use a text field. I have built additions to text fields for ACF.

    First I add a setting to all text fields

    add_action('acf/render_field_settings/type=text', 'validate_text_as_href_setting');
    function validate_text_as_href_setting($field) {
      // this addes a setting to text fields
      // setting it to true will require that the content of the fields
      // meets requirements to be used as a link href value
      $args = array(
        'label' => 'Validate as HREF',
        'instructions' => 'Requires a valid href attribute. This includes values starting with: http://, https://, ftp://, mailto:, tel:, sms: /, and #',
        'type' => 'true_false',
        'name' => 'validate_href',
        'ui' => 1,
        'class' => ''
      acf_render_field_setting($field, $args);

    The I have a validation filter for all text fields

    add_action('acf/validate_value/type=text', 'validate_text_as_href', 10, 4);
    function validate_text_as_href($valid, $value, $field, $input) {
      // if the setting created by validate_text_as_href_setting
      // is true than this filter will text input to ensure it can
      // be used in as a link href value
      // this allows links starting with
      // / (site root relative), http://, https://, ftp://, # (anchor), mailto:, tel:
      if (!$valid) {
        return $valid;
      if (isset($field['validate_href']) && $field['validate_href'] && !empty($value)) {
        if (!preg_match('%^(https?\://|ftp\://|/|#|mailto\:|sms\:|tel\:)%i', $value)) {
          $valid = 'Enter a Valid HREF Value';
      return $valid;

    I use another text field for the link text.

    then, of course there is the code to add to show the link

    <a href="<?php the_field('my_link_field"); ?>"><?php the_field('my_link_text_field'); ?></a>
  • Oh wow! I actually found a much simpler solution using Elementor. Please see screenshot:

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

The topic ‘Add a subject line to Email mailto?’ is closed to new replies.