0

I am trying to use slick slider and want to display 3 authors per slide with following code.

    $authors=get_users();
$i=0;
//get all users list
foreach($authors as $author){
    $authorList[$i]['id']=$author->data->ID;
    $authorList[$i]['name']=$author->data->display_name;
    $i++;
}
?>
<div class="sidebar-authors-custom better-slider" id="sidebar-authors-custom">
    <?php 
    foreach($authorList as $author){
        $args=array(
                'showposts'=>1,
                'author'=>$author['id'],
                'caller_get_posts'=>1
               );
        $query = new WP_Query($args);
        if($query->have_posts() ) {
            while ($query->have_posts()){
                $query->the_post();
    ?>
    <?php if($author['id'] != 1){ ?>
      <a href="<?php echo get_permalink(); ?>"><div class="author">
            <div class="profile-img">
            <?php echo get_avatar( $author['id'] , 80); ?>
            </div><div class="profile-info"><span class="name"><?php echo $author['name']; ?></span>
            <span class="title"><?php echo get_the_title(); ?></span></div></div></a>
      <?php }}}} ?></div>

I added following lines to my functions.php in order to get CSS and JS files of slick slider properly. I checked from the source and it works.

    //Additional CSS
    wp_enqueue_style( 'slick', get_template_directory_uri() . '/css/slick.css');

    //Additional JS
    wp_enqueue_script( 'slick', get_template_directory_uri() . '/js/slick.js', array ( 'jquery' ), 1.1, false);

I added the following lines both in slick.js file and the page from WP Bakery interface which should fire the slider and load its components within DOM. (I altered JQuery to Vanilla JS for the page)

    $(document).ready(function(){
    $('#sidebar-authors-custom').slick({
  dots: true,
  infinite: true,
  speed: 300,
  slidesToShow: 1,
  adaptiveHeight: true
  });
 });

But I see no changes and have no issues on console. I thought maybe it is about the JQuery version and tried the following code either.

wp_register_script( 'jquery3.2.1', 'https://code.jquery.com/jquery-3.2.1.min.js' );
wp_add_inline_script( 'jquery3.2.1', 'var jQuery3_2_1 = $.noConflict(true);' );
wp_enqueue_script( 'plugin-javascript', plugins_url( 'js.js', __FILE__ ), array( 'jquery3.2.1' ) );

Still no changes. Could anyone help me with that?

  • Try with jQuery(document).ready(function($){ – Sally CJ Jul 8 '18 at 13:00
  • Tried just now but still no changes @SallyCJ – Özgür Polat Jul 8 '18 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.