Plugin Support
dimned
(@dimned)
Hi @celes15,
Here is a code that will work on the front-end only
window.addEventListener( 'load', function() {
const baseClass = 'wp-block-getwid-post-carousel';
const loadSlickContent = setInterval( () => {
const sliderSelector = $( 'body' ).find( <code>.${ baseClass }</code> ).children();
console.log( sliderSelector );
if ( sliderSelector[ 0 ] ) {
[sliderSelector].forEach( slider => {
slider.hasClass( 'slick-initialized' ) && slider.slick( 'unslick' );
slider.imagesLoaded().done( () => {
slider.not( '.slick-initialized' ).slick( {
arrows: true,
} );
} );
} );
clearInterval( loadSlickContent );
}
}, 100 );
} );
Let me know if it is helpful.
Great π
I done small change
baseclass deleted and swap sliderSelector
const sliderSelector = $('.wp-block-getwid-post-carousel').children();
Thanks
-
This reply was modified 4 years, 11 months ago by
celes15.
Plugin Support
dimned
(@dimned)
You are welcome @celes15. It would be helpful if you review the plugin here https://wordpress.org/support/plugin/getwid/reviews/
Eh… it’s simetimes work but not always…
I must force load like last script ?
Plugin Support
dimned
(@dimned)
Hi @celes15,
You need to enqueue the script in this way
function global_script_setup()
{
wp_enqueue_script( 'your-name', get_theme_file_uri( '/assets/js/file-name.js' ), array( 'jquery' ), wp_get_theme()->get( 'Version' ), true );
}
add_action( 'init', 'global_script_setup' );
hi @dimned
Yeah I enqueued it earlier π
With delay – jquery, slick and imagesloaded.
Link to page
Sometimes it working sometimes not π
-
This reply was modified 4 years, 10 months ago by
celes15.
Plugin Support
dimned
(@dimned)
Hi @celes15,
It looks like you have put 50 milliseconds instead of 100. Please, try to put back 100 milliseconds for correct slider initialization.