Skip Navigation

[Resolved] Create links with Toolset ShortCodes

This thread is resolved. Here is a description of the problem and solution.

Problem:
Can we create links with ShortCodes, so for example add Image URLs to fancybox features, or images as links, etc?

Solution:
Yes, it's described in more depth here.
https://toolset.com/forums/topic/how-to-insert-a-dynamic-featured-image-with-a-link-to-the-media-file/#post-1191452

This support ticket is created 5 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 2 replies, has 2 voices.

Last updated by joe-enteleos 5 years, 3 months ago.

Assisted by: Beda.

Author
Posts
#1191384

In a layout, view, or content template used on a single post template, it is easy to insert a shortcode for the featured image of a post. I'm trying to figure out how to have that image link to the media file, so clicking on the image will either open the media file or open it in a lightbox.

I've done this with Elementor inserting a Featured Image widget that links to the media file into the custom post type's single post template. In the example here: hidden link you can click on the main image at the top to open the media file in a lightbox.

As you'll see, I've been able to link the featured images for the related posts displayed on this template to the post itself using the Post URL shortcode in the relevant content template and view. But I haven't figured out how to link the featured image for the post page itself to the media file.

I'm trying to do this without Elementor. Can you suggest the best way to accomplish this?

Thank you!

#1191452

When you insert the Image ShortCode or Featured Image ShortCode you can decide whether to output the image or another kind of data, such as the URL, which helps you to create things like lightbox.
Also, it allows you to choose what post from to display the data.

As an example from a customized solution where fancybox is used

<a data-fancybox="gallery" href="[types field='slide-image' url='true' ][/types]"><img src="[types field='slide-image' size='image-slider' url='true'][/types]"></a>

Or, some of these solutions:
https://toolset.com/forums/topic/how-to-get-a-lighbox-effect/
https://toolset.com/forums/topic/making-image-gallery-display-with-light-box/
https://toolset.com/forums/topic/lightbox/
https://toolset.com/forums/topic/open-image-in-lightbox-with-views/

Is this what you are looking for?

#1191518

I'm good now. The keys: Realizing that I could add the shortcode for Featured Image and choose to output the URL to the image, and use that in a link tag surrounding the shortcode for displaying the image itself. Plus, I've installed ARI Fancy Lightbox Pro and needed to choose "Convert links to images" in the settings.

Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.