- This topic has 11 replies, 6 voices, and was last updated 1 month, 4 weeks ago by
David.
-
AuthorPosts
-
September 13, 2021 at 1:40 pm #1929374
Jeff
I’m creating an archive page for a custom post type; ACF for custom fields.
There’s a field named “contact_email”.
I can successfully add a dynamic headline to display the email address.
But when I try to create a mailto link, the system adds “http://” followed by the email address β instead of “mailto:”.
Am I doing something wrong?
Is there a workaround? How can I get GP Premium to use mailto?
Thanks.
September 14, 2021 at 6:53 pm #1930786Tom
Lead DeveloperLead DeveloperHi there,
In your dynamic link, make sure it’s set to
#
.Then it should pull in the full
mailto:you@you.com
if you add it like that to the custom field.So the system will replace
href="#"
withhref="your-custom-field-value"
.Let me know π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentOctober 14, 2021 at 12:17 pm #1963665Brenden
This worked for me. Thank you!
October 14, 2021 at 7:44 pm #1963903Tom
Lead DeveloperLead DeveloperNo problem!
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentDecember 14, 2021 at 4:48 pm #2049317Jason
I’m a bit unsure about getting this to work.
My ACF field is set as email type for validation, thus including ‘mailto:’ within the field content is prohibited. How should I set this up to enable this for the email and also for a phone field for ‘tel:’?December 15, 2021 at 11:38 am #2050339Tom
Lead DeveloperLead DeveloperWe would need to filter the output in that case.
For example:
add_filter( 'generate_dynamic_element_url', function( $url, $link_type, $source, $block ) { if ( 'post-meta' === $link_type ) { $meta_name = $block['attrs']['gpDynamicLinkCustomField']; if ( $meta_name && 'your-email-meta-field-name' === $meta_name ) { $url = 'mailto:' . $url; } if ( $meta_name && 'your-tel-meta-field-name' === $meta_name ) { $url = 'tel:' . $url; } } return $url; }, 10, 4 );
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentDecember 15, 2021 at 3:30 pm #2050480Jason
Thanks Tom,
As always you came through with the goods, works a treat!
Much appreciatedDecember 16, 2021 at 2:41 pm #2051423Tom
Lead DeveloperLead DeveloperGlad I could help! π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentDecember 9, 2022 at 3:55 am #2455690Christian
Hi Tom,
I followed all your instructions, but did not achieve success. Regardless that it works straightforward to create nice author boxes, firstly, thanks for that ^.^/
The Link button is set to #, the dynamic option (Link Type) is set to Author Meta and the Field Name is set to user_mail.
Nevertheless, the button does not pull any mail afterwards, only the root domain.
Do you have any ideas what this could be? All other links work (like LinkedIn).
Thanks in advance,
ChrisDecember 9, 2022 at 5:02 am #2455758David
StaffCustomer SupportHi there,
did you update the meta names in Toms code here ?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/December 9, 2022 at 5:17 am #2455770Christian
Hey David, thank you for the reply!
Good hint.
I have now added the code to the customizer as follows (I hope this is the right approach):
add_filter( ‘generate_dynamic_element_url’, function( $url, $link_type, $source, $block ) {
if ( ‘post-meta’ === $link_type )$meta_name = $block[‘attrs’][‘gpDynamicLinkCustomField’];
if ( $meta_name && ‘user_email’ === $meta_name ) {
$url = ‘mailto:’ . $url;
}
}return $url;
}, 10, 4 );The box is still pulling the domain. I will try it again later though π
December 9, 2022 at 7:30 am #2455951David
StaffCustomer SupportLet us know how you get on!
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/ -
AuthorPosts
- You must be logged in to reply to this topic.