Archived topic
Dynamic URL not working in Elements
10 replies · Started by troyw on January 27, 2022
Hey team,
Not sure what is happening, but I am using a Block Page Hero Element and using the Dynamic Headlines to pull in data. Using Dynamic Text Type, I have selected 'Post Meta' and under Meta Field Name 'website_url'. This has grabbed the Url for me and it even changes color when you hover over it, but the link does not work.
What am I doing wrong?
Thanks
Hi there,
Can you confirm if the Dynamic link type is set for the Headline block you're pertaining to?
It should look something like this - https://share.getcloudapp.com/Qwu4LzGW
That is it Elvin, I knew I was missing something important there.
Is there a way to make it open in new window?
Thanks so much
No problem. Glad you got it sorted. Let us know if you need further help. :D
Sorry Elvin, is there a way to make the link open in a new window?
You can try adding a unique class to this dynamic heading through its Advanced > Additional CSS class(es) and add this Javascript.
Example: If you assign website_url the class.
You can place this code on a hook element hooked to wp_footer w/ the display rule location similar to this Block element - Page hero.
<script>
const website_url = document.querySelector('.website_url > a');
window.onload = function(){ website_url.setAttribute('target', '_blank'); }
</script>
Sorry Elvin, you've completely lost me.
Am I adding website_url to the Block Page Hero Element Advanced > Additional CSS class(es)?
Do I create a new Hook element?
It OK, I got it. Thanks Elvin
Am I adding website_url to the Block Page Hero Element Advanced > Additional CSS class(es)?
Ah my bad. It has to be on the Headline Block with the dynamic text/link.
And yes you have to create a new Hook element hooked to wp_footer with the same Display rule location as this Block element - page hero so the code I've provided will only run on the same pages as this Block element - Page hero. :D
Awesome, all working perfectly now. Have a great weekend!
No problem. You too! Stay safe! :D