Support

Account

Home Forums ACF PRO Url and Email field

Solving

Url and Email field

  • Just curious but I can’t find these in the documentation, do they have any special properties? The Url field has the world globe icon but I can’t detect anything else..

  • They are just standard fields, nothing special from what I know. Just use your standard get_field and the_field to output the data.

  • Not to highjack a thread, but related to this, how would I output the email address (from a backend email field) on the front end, in a mailto: link? Example, let’s say in the back end there is information entered for John Doe, e-mail address is [email protected]. On the front end, I want to display a link that says E-mail, with mailto:[email protected] as the link. Thanks for any input!

  • To the first point, yes they are just standard fields but require that a valid URL or an email address be entered.

    second question

    
    <?php 
      <a href="mailto:<?php the_field('email_field_name'); ?>">E-Mail</a>
    ?>
    
  • @hube2 Thank you! I will try that. Is there a way to do the same with a shortcode? I am creating a site for someone using the Divi theme, and putting the code into the page builder (even the ‘code’ module) isn’t working. They won’t want to be editing template files in the future.

  • acf has a simple shortcode that can be used in the content area in WP that is documented here http://www.advancedcustomfields.com/resources/shortcode/

    Basically it would be something like this when editing in text mode, but to be honest I don’t know if this will work with the changes that WP has recently made to the way shortcodes work. You’d have to try it.

    <a href='mailto:[acf field="field_name"]'>E-Mail</a>

    I’m not familiar with the Divi and don’t know if it will work there.

  • @hube2 Thank you, the shortcode one works! For some reason, the php one doesn’t work.

  • The php one not working may have someting to do with the framework you’re using or some other incompatibility.

  • Hi there, I’ve tried both of these options and the mailto: link is not going anywhere?

    Is there anything I’m doing wrong? This is what I’ve entered into the Divi template:

    <i class=”fas fa-envelope” style=”color: #2e7df4; padding-right: 10px;”></i>[acf field="email"]

    and when I test it, it only prints to mailto:[acf field="email"] and not the email entered into the custom field.

    Any ideas?

  • @karlapizzica it depends on where you’re putting that code what the solution would be. Is that in a template somewhere or are you trying to put that into a field of some type?

  • Oh okay. So what I’m doing is I’ve created a template within Divi for a single post.

    The custom fields are within the template to be used whenever the user creates a post. I used it within the Divi Template builder which is essentially customising the template of custom pages. This one is single.php.

    I’ve provided a link for you to see what I mean:

    https://thehellodirectory.com/hello-mojo-app/

    You’ll see the right sidebar populated with custom fields (website, email, phone number etc).

  • 
    <i class="fas fa-envelope" style="color: #2e7df4; padding-right: 10px;"></i><?php echo do_shortcode('[acf field="email"]'); ?>
    
  • Hi there,

    When I use this:

    <a href='mailto:[acf field="email"]'>E-Mail</a>

    The mailto: is empty but when I just place the shortcode [acf field="email"] the email address is displayed as it should.. I’m using the DIVI builder.

    Any suggestions? it’s driving me nuts to put a simple email link in my page 🙁

    Thanks,
    Bertus.

  • Hi there,

    Did you ever solve this? I’m having the exact same issue trying to get a simple link to work.

  • Just in case anyone is interested in this – I managed to hack together a solution.

    I added the following code to the Divi functions.php file to create a simple shortcode. You then just add the shortcode [contact_email] into the code block in Divi:

    add_action('init', function(){
        add_shortcode('contact_email', function(){
            return '<a href="mailto:' . get_field('contact_email') . '">E-Mail</a>';
    
        });
    });
  • I realize I am late to this thread, but after a week of pulling my hair out with this, and having none of the above options work, nor any others online, I randomly stumbled across a resolution today and successfully created mailto: links with Divi & ACF. I created a tutorial in hopes that someone else won’t spend a week trying to figure it out.

    Hope this helps: http://keilassociates.com/divi-advanced-custom-fields-email-link-not-sending.html

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

The topic ‘Url and Email field’ is closed to new replies.