Hi,
I am trying to execute a 3rd party shortcode from View which will popup an appointment booking form with calendar when a button is clicked. Here's my html code under Loop item in View:
[wpml-string context="wpv-views"]Book a tour[/wpml-string]
The shortcode "sg_popup" works in a post/page but doesn't work this way. How can I make it work? Your help is most appreciated..
What is the link to your site?
hidden link
I honestly don't know.
The first test I suggest is this:
1. Insert this code into a simple Post Body, in text mode:
<a href="[sg_popup id=1]" class="btn btn-tour">[wpml-string context="wpv-views"]Book a tour[/wpml-string]</a>
Does it "work"?
If no, then this issue has to be directed to the creator of that ShortCode, which is not Toolset.
2. If it works, please let me know the exact output of the ShortCode (inclusive eventual HTML)
I assume it produces a bit more than a URL and breaks the HTML Link.
I don't think this is a Toolset issue.
What I can think of is that your ShortCode's ID attribute expects something like a Post ID, hence passing "1" is wrong, in a Post View Loop.
[wpv-post-id] would be better in this case (given the 3rd party ShortCode accepts nested ShortCodes, which is not granted).
Please let me know the results.
The <a> itself doesn't work. It gives the message: "Sorry, but the page you were trying to view does not exist." But if using the shortcode: "[sg_popup id=1]" alone in the post body, it works as attached. How can I get this to pop in View?
Well, it seems this ShortCode produces a whole lot more than a simple URL?
In that case, you can logically not use it as an "a href=" parameter.
This is the HTML that has to be created by a "a href":
<a href="www.url.com" class="any-class">Any Text</a>
If your shortcode "[sg_popup id=1]" produces what I see in the ScreenShot, then this is much more than a URL.
It's a whole calendar and a Form.
This can not be used as a URL href, as that needs to be an URL.
Since you use this ShortCode as a standalone in the Single Posts, it also needs to be used as a StandAlone in the Views loop.
Since it seems to accept an ID, you can try to pass the dynamic ID [wpv-post-id] which will make sure to give the right ID to the ShortCode.
Thanks Beda. That will definitely work if I link to a post where the shortcode is called.