-
birdhousedigital
Hello,
I have a custom field called email_address which contains an email address. I want a button to link to this. When I add {{post_meta key:email_address}} I get the domain portion of the address only. How do I link to the actual email address?My second question is about an elfsight embed code. I have this in an acf field, and want to show it via a template. I have this added to my template as {{post_meta key:linkedin_embed_code}} however it’s not coming through?
Many thanks,
Abby -
Alvind
Hi there,
I can’t view the page because it seems to require authentication.
Regarding the email address link, do you mean that clicking it should open the mail client?
-
birdhousedigital
Yes! Sorry, I’ve removed the URL protection so you can now access the staging site.
-
Alvind
For the email link issue, try adding this snippet:
function modify_email_links($block_content, $block) { // Only modify blocks that contain the "Button1" class or other identifier if (strpos($block_content, 'Button1') !== false) { // Use regex to find email addresses in href attributes $pattern = '/<a[^>]*href="http:\/\/([^"@]+@[^"]+)"[^>]*>/i'; $replacement = '<a class="gb-text Button1" href="mailto:$1">'; // Replace the http:// link with mailto: $block_content = preg_replace($pattern, $replacement, $block_content); } return $block_content; } add_filter('render_block', 'modify_email_links', 10, 2);
For the secind issue – I see that you’re using the HTML block for the embed code. Unfortunately, Dynamic Tags are not supported in the HTML block—or in any non-GB block, for that matter.
-
birdhousedigital
Thanks, the email snippet works perfectly.
The html field was just a left over from some testing. Above it is the text field with the dynamic tag.See photo at https://snipboard.io/qx0KRk.jpg
I have another question. I have a dynamic image field where I which is pulling in images. Some posts have 4 and some have 3. I have this set as a 4 column grid, however where there are only 3 images being pulled in is it possible to have the grid centred on the page, rather than 3 images and then one empty column? Ideally I’d use a carousel but I’m tying to stick with GB for simplicity at this point.
-
Thanks, the email snippet works perfectly.
Actually, you don’t need this snippet if you are using v2. I think Alvind might’ve overlooked the problem.
You can add mailto: before the link destination, so if your dynamic link for link is
{{post_meta key:email_address}}
, you just need to change it tomailto:{{post_meta key:email_address}}
.Here’s a screenshot for your reference:https://app.screencast.com/Bj2NKFazearUj
I have another question. I have a dynamic image field where I which is pulling in images.
I don’t think it’s possible, but I can take a look at it, where can I see it?
-
birdhousedigital
Oh that’s even better. I thought I’d tried that configuration for the email but obviously I’d done it wrong somehow!
This is in my Partner City Content template, and is the container called ‘Unique Venues’.
-
1. select the Looper block of the section, go to the style tab, click More button to open up the selector panel, click +New to create a new selector, then enter
:not(:has(.gb-loop-item:nth-of-type(4)))
, and toggle the Compound selector option.2. Now you’ve create a selector called
.gb-looper-6ecee2dc:not(:has(.gb-loop-item:nth-of-type(4)))
, setwidth
to 75%,margin-left
andmargin-right
toauto
, and setgrid-template-columns
torepeat(3,minmax(0,1fr))
.I’ve made the change in your element, please take a look 🙂
-
birdhousedigital
That’s fantastic – thank you!
Just the elfsight embed code now. It is in my template as {{post_meta key:linkedin_embed_code}} however it’s not coming through?
-
Sorry I can not find it, there’s a lot of content in that element, Can you let me know which block it is?
Thanks!
-
birdhousedigital
Yes there is!
It’s in the container called ‘linkedIn embed’.
https://snipboard.io/scBpT6.jpg -
The content in the text area field has HTML tags like
<script>
; the dynamic tag might not support html tags.Can you try adding static text to the text area to see if the dynamic tag can pull the data?
-
birdhousedigital
Ah yes, it pulls through static text and also a direct LinkedIn embed. Just not the elfsight code. I’ll look for another way to pull the LinkedIn feed into the site.
-
Hopefully ACF shortcode will work for that one 🙂
- You must be logged in to reply to this topic.