Is it possible to create a link to a slide in slick slider? Example: my goal is to create QR codes with the URL of a page and load the slider and the current slide is number 5.
You could do it a few ways but given that you want to create URL's you could pass in the slide number as a query string for example you have a website called www.example.com you have a hyperlink set to your page like so www.example.com/subpage/?slideNum=2
On the page where you have your slick-slider you would add an event to first listen for the slick slider being created, then check to see if there is a URL parameter set to do a slickGoTo event like so:-
$(".slick").on("init", function (e, slickInstance) {
const params = new URLSearchParams(window.location.search);
const myParam = params.get("slideNum");
if (Number(myParam)) {
slickInstance.slickGoTo(myParam);
}
});
$(".slick").slick({
centerMode: true,
slidesToShow: 1
});
This method allows you to still go to the URL with or without a query parameter and also offers flexibility for you to change the slide number relatively easily.