有人有使用url在Soliloquy滑块中定位特定幻灯片的经验吗?我正在使用多个滑块,我需要从外部页面/网站链接到的特定幻灯片。Soliloquy Docs提供了最接近解决方案的信息(solilogywp.com/Docs/动态设置起始幻灯片/),但对于像我这样的php noob来说,解释有点简洁和缺乏,这是我的错,而不是他们的错。
文档中给出的示例似乎是特定滑块中特定幻灯片的自定义过滤器。我需要在多个带有url的滑块中定位幻灯片。我想我需要帮助理解过滤器的功能。我已经评论了我认为每一部分的作用。也许有人能告诉我哪里错了?
//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的滑块中的任何幻灯片。几率很小,但我已经死在水里了!非常感谢任何能为我阐明这一点的人。
这里提供了完整、正确运行的答案,当然是插件作者duh:http://soliloquywp.com/support/topic/a-way-to-link-directly-to-a-specific-slide/
值"sol_slide"对于使用插件创建的任何滑块都是通用的。只需将示例中提供的自定义过滤器放入子主题的functions.php中,并构建针对特定幻灯片的URL,如下所示:http://mywebsite.com/specific-product-page-with-slider/?sol_slide=3.幻灯片编号是以零为基础的,因此1=2等。工作起来很有魅力。