Skip Navigation

[Resolved] Screenshot in a slider with custom shortcode

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

Problem:
The client has created a custom shortcode to display a slider, but the slider appears in the wrong place.

Solution:
The shortcode echoes the output. Shortcodes should always return the string to be output.

This support ticket is created 6 years 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 6 years ago.

Assisted by: Nigel.

Author
Posts
#801730
Skærmbillede 2018-05-03 10.29.31.png

I want a screenshot of a page to be the used in a slider:

I have this shotcode in my functions.php
[code]
add_shortcode('ss_screenshot', 'ss_screenshot_shortcode');
function ss_screenshot_shortcode($atts){
$width = intval($atts['width']);
$width = (100 <= $width && $width <= 300) ? $width : 165;
$site = trim($atts['site']);

if ($site != ''){
$query_url = 'hidden link' . urlencode($site) . '?w=' . $width;
$image_tag = '<img class="ss_screenshot_img" alt="' . $site . '" width="' . $width . '" src="' . $query_url . '" />';
echo '<a class="ss_screenshot_link" href = "' . $site . '">' . $image_tag . '</a>';
}else{
echo 'Bad screenshot url!';
}
}
[/code]

and this is the view template

[code]
<div class="subject-slide">
<div class="subject-icon">
[ss_screenshot site="[wpv-post-url]"]
</div>
<div class="subject-title">
[wpv-post-link]
</div>
</div>
[/code]

But toolset puts all screenshots above the slider in one row.

#801921

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Jesper

The View you have created is a slider View, that's how you are making the slider, right?

I think your problem may be as simple as your shortcode is echo-ing the string you have constructed, but should return it instead.

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