Hi, I'm trying to insert a dynamic URL into an iframe code and am having some issues. I've read through countless support tickets and help articles, and for some reason I just can't get it to work. I think the issue is because I'm trying to pull the URL from a parent relationship's custom post, so I'm using the item attribute in the short code. Anyways, I came across this previous support ticket that involves creating a custom shortcode and I think this could be a good solution (https://toolset.com/forums/topic/add-an-iframe-to-elementor-using-dynamic-url/). However, I'm curious how I can get this one to work since I am using the item attribute? To make matters more complex, I'm also wrapping it within a conditional shortcode that also checks to see if this parent custom field is empty or not in order to display it.
The iframe I am trying to use is not a video embed or anything that's supported by WordPress' built-in functionality. It's from a Matterport 3D property tour.
Here's an example of what I was trying to do previously with no success:
[wpv-conditional if="( '[types field="matterport-tour" item="@property-floor-plan.parent"][/types]' ne '' )"]
<h1>3D Tour</h1>
<iframe width="853" height="480" src="[types field='matterport-tour' item='@property-floor-plan.parent' output='raw'][/types]" frameborder="0" allowfullscreen allow="xr-spatial-tracking"></iframe>
[/wpv-conditional]
I've already verified that the [types] shortcode is written correctly with how my fields are entered and connected on the back-end, as that will work in other implementations, just not with the iframe.
So, interestingly enough, when I try the shortcode independently as just [types field="matterport-tour" item="@property-floor-plan.parent"][/types], it outputs the URL text and it's hyperlinked automatically.
But, when I try the shortcode independently with the included output="raw" attribute, it tries to automatically format it as an iframe (looking at the page source code) and it just shows up as a blank square box. That's probably where the issue lies. But, in my above example, it didn't work regardless if I put output="raw" or not.
So, if we can somehow get it to just output the raw URL instead of the auto-iframe formatting it's doing while using the "output="raw" attribute, it should work. Is there an alternative way to write this up that might avoid this issue?
Sorry Nate, there was a glitch in our system and this thread has been lost in no-man's land until now.
Looking at your reply, I don't understand "it tries to automatically format it as an iframe", inasmuch as the Types url shortcodes has nothing to do with iframes and either outputs links or URLs, the iframe comes from using the types shortcode in an iframe element.
To try to understand what's going on I think I'd need access to your site to see for myself, if that's possible.
Let me mark your next reply as private so that we can get log-in credentials from you—you may want to create a temporary admin user for us to use that you can later delete. And be sure to have a current backup of your site.
Can you also confirm the url of where we can see the problem.
The topic ‘[Closed] Inserting a Dynamic URL into an iframe code’ is closed to new replies.