C
C
criro19962019-07-24 14:31:47
Slick
criro1996, 2019-07-24 14:31:47

Slick Slider not working in Wordpress?

Good afternoon , installed vp , included styles and scripts via fanctions.php . I have a slick-slider under the menu. It is not displayed as a slider, but is displayed in 4 lines. Re-registered jquery . Did not help. Responsive menu works, probably not in jquery problem.

<?php 


add_action( 'wp_enqueue_scripts' , 'my_styles' );
add_action( 'wp_enqueue_scripts', 'my_scripts' );
add_action( 'wp_enqueue_scripts', 'my_lol' );



function my_styles(){
  wp_enqueue_style('style', get_stylesheet_directory_uri());

  wp_enqueue_style('stylecss' , get_template_directory_uri() . '/assets/css/style.css');

  wp_enqueue_style('slicktheme' , get_template_directory_uri() . '/assets/css/slick-theme.css');

  wp_enqueue_style('slick' , get_template_directory_uri() . '/assets/css/slick.css');

  wp_enqueue_style('bootstrap' , get_template_directory_uri() . '/assets/css/bootstrap.css');

  wp_enqueue_style('bootstrapmin' , get_template_directory_uri() . '/assets/css/bootstrap.min.css');

  

}

function my_scripts() {

  wp_deregister_script( 'jquery' );

  wp_register_script( 'jquery', get_template_directory_uri() . '/assets/js/jquery-3.4.1.min.js' );

  wp_enqueue_script( 'jquery' );

  wp_enqueue_script('popper', 'https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js');

  wp_enqueue_script('slickjs', get_template_directory_uri() . '/assets/js/slick.min.js', ['jquery']);

  wp_enqueue_script('bootstrapjs', get_template_directory_uri() . '/assets/js/bootstrap.min.js', ['jquery']);

  wp_enqueue_script('common', get_template_directory_uri() . '/assets/js/common.js', ['jquery']);

  wp_enqueue_script('kit', 'https://kit.fontawesome.com/3ada3c02e7.js');

}



function my_lol() {
  wp_deregister_script( 'jquery' );

  wp_register_script( 'jquery',  get_template_directory_uri() . '/assets/js/jquery-3.4.1.min.js');

  wp_enqueue_script( 'jquery' );
}

In the debugger writes that everything is connected. What to try to fix, tell me.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
andrash_, 2019-07-24
@andrashsh

Follow my example .. WordPress already connects jQuery for you, you just need to register dependencies for it.

function theme_scripts() {
  wp_enqueue_style( 'theme-style', get_stylesheet_uri() );
  // Custom scripts
  wp_enqueue_script( 'custom-common', get_template_directory_uri() . '/js/common.js', array('jquery'), null, true );

  // Bootstrap
  wp_enqueue_script( 'bootstrap-popper', '//cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js', array('jquery'), null, true );
  wp_enqueue_script( 'bootstrap-min', '//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js', array('jquery'), null, true );
  // Owl carousel JS
  wp_enqueue_script( 'owl-carousel', get_template_directory_uri() . '/libs/owl-carousel/owl.carousel.min.js', array('jquery'), null, true );
  // Phone mask
  wp_enqueue_script( 'masket', get_template_directory_uri() . '/libs/inputmask/inputmask.js', array('jquery'), null, true );
  wp_enqueue_script( 'extensions', get_template_directory_uri() . '/libs/inputmask/inputmask.extensions.js', array('jquery'), null, true );
  wp_enqueue_script( 'num-extensions', get_template_directory_uri() . '/libs/inputmask/inputmask.numeric.extensions.js', array('jquery'), null, true );
  wp_enqueue_script( 'inputmask', get_template_directory_uri() . '/libs/inputmask/jquery.inputmask.js', array('jquery'), null, true );
}
add_action( 'wp_enqueue_scripts', 'theme_scripts' );

array('jquery'), null, true - ( dependency on jQuery, remove version, place in footer ).
wp_enqueue_script - immediately registers the style and adds it to the theme, specify a different $handle for scripts and styles.
If you have your own .js file
jQuery( document ).ready(function( $ ){
 //code
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question