So, I am trying to display Testimonials with Slick slider but it is not working. I guess I linked the css and js files wrong or something because testimonials are displaying but slider doesn’t work. So please help with troubleshooting.
This is code:
HTML
<section class="reviews">
<div class="row d-flex flex-column">
<div class="testimonial-holder">
<?php
$args = array(
'post_type' => 'testimonials',
// 'post_status' => 'publish',
// 'posts_per_page' => 1,
// 'order' => 'ASC',
);
$query = new WP_Query( $args );
?>
<?php
while( $query->have_posts() ) :
$query->the_post();
?>
<div class="lead-text d-flex text-center justify-content-center flex-column">
<?php echo '<p class="lead">' . get_the_content() . '</p>' . '<small>' . '-' . get_the_title() . '</small>'; ?>
</div>
<?php endwhile;
wp_reset_postdata(); ?>
</div>
</div>
</section>
ENQUE
function load_css() {
wp_register_style( 'slick', get_template_directory_uri() . '/src/js/slick/slick.css', array(), false, 'all' );
wp_enqueue_style('slick');
}
add_action( ‘wp_enqueue_scripts’, ‘load_css’ );
function load_js() {
wp_register_script( 'slick', get_template_directory_uri() . '/src/js/slick/slick.min.js', false, true);
wp_enqueue_script('slick');
}
add_action( ‘wp_enqueue_scripts’, ‘load_js’ );
CALLING IT WITH JQUERY//This is only line of code and it should work
$('.testimonial-holder').slick();
2
Answers
At the end I pulled this off with Advanced Custom Fields with number field. I gave up on slider and changed the concept little bit. So, depends of the entered number in the filed, it will generate number of stars in the Front end.
Did you attach the .slick() callback on document.ready state?