使用url在Soliloquy滑块中定位特定幻灯片

时间:2014-04-16 14:08:07

标签: slider

有没有人有使用网址定位Soliloquy滑块中特定幻灯片的经验?我正在使用多个滑块,我需要链接到外部页面/网站的特定幻灯片。 Soliloquy Docs提供此信息(soliloquywp.com/docs/dynamically-set-the-starting-slide/)最接近解决方案,但对于像我这样的php noob,解释有点简洁,缺乏,我的错,不是他们的。

文档中给出的示例似乎是特定滑块中特定幻灯片的自定义过滤器。我需要使用网址在多个滑块中定位幻灯片。我想我需要帮助理解过滤器的功能。我已经评论了我认为每个部分的作用。也许有人可以告诉我哪里错了?

//OP: I don't understand, what ids/slides are represented by the 10 and 2 values in these parameters. Where do I find these?
add_filter( 'soliloquy_pre_data', 'tgm_soliloquy_dynamic_starting_slide', 10, 2 );
function tgm_soliloquy_dynamic_starting_slide( $data, $slider_id ) {
// If the proper $_GET parameter is not set or is not the proper slider ID, do nothing.
//OP: Is the 'sol_slide' parameter for ALL soliloquy sliders in my site or is it the name in the Dashboard given when constructing the slider?
if ( empty( $_GET['sol_slide'] ) ) {
return $data;
}
// Change this if you want to target a specific slider ID, or remove altogether if you want this for all sliders.
//OP: I believe to target ALL sliders in my site I should comment this out. Right?
if ( 51064 !== $slider_id ) {
return $data;
}
// Set the slide number as a config property. Also preventing randomizing slides.
$data['config']['start'] = absint( $_GET['sol_slide'] );
$data['config']['random'] = 0;
// Optionally prevent autostarting the slider. Uncomment if you want that.
//$data['config']['auto'] = 0;
return $data;
}

基本上,我想我要求帮助实现此过滤器以使用url定位任何滑块中的任何幻灯片。可怜的赔率,但我死在水里!非常感谢能够为我揭示这一点的人。

1 个答案:

答案 0 :(得分:0)

插件作者提供完整,功能正常的答案,当然,duh:http://soliloquywp.com/support/topic/a-way-to-link-directly-to-a-specific-slide/

值“sol_slide”对于使用插件创建的任何滑块都是通用的。只需将示例中提供的自定义过滤器放入您希望的子主题的functions.php中,然后构建针对特定幻灯片的网址,如下所示:http://mywebsite.com/specific-product-page-with-slider/?sol_slide=3。幻灯片编号基于零,因此1 = 2等。就像魅力一样。