Hi @chrimbus,
you can enqueue Slick’s assets on any template you want. To do this, follow the steps described in Is it possible to use slick’s JS and CSS independently?.
Then, add the following code to your (child theme’s) function.php to enqueue an inline initialization script for your custom class whenever Slick’s assets are enqueued:
add_action( 'wp_enqueue_scripts', function() {
wp_add_inline_script( 'slick-slider-core', file_get_contents( get_stylesheet_directory() . '/assets/js/slick-slider-custom.js' ) );
}, 11 );
Create the file slick-slider-custom.js
in your (child) theme’s assets/js/
folder and paste the following code:
jQuery( document ).ready( function() {
jQuery( '.slick-class-target' ).slick();
} );
That’s all.
Note: You may have to adjust the location of the JavaScript file according to your (child) theme file structure.
I hope this works for you. If it does, please set this thread’s status to resolved
. Thanks.