I
I
Ivan Medvedev2021-11-09 04:09:30
WordPress
Ivan Medvedev, 2021-11-09 04:09:30

Why is the script not connected to the basement?

Good day, friends! Tell me, why can't I connect scripts to the basement? In the header, they are connected as standard, and when I enter the value true, the script immediately turns off

add_action('wp_enqueue_scripts', 'site_scripts');
function site_scripts () {
    $version = '0.0.0.1';
    wp_dequeue_style('wp-block-library');
    wp_deregister_script('wp-embed');
    
    wp_enqueue_style('main-style', get_stylesheet_uri(), [], $version);
    wp_enqueue_script('slick', get_template_directory_uri() . '/slick/slick.min.js', ['jquery'], $version);
}

add_action( 'init', 'true_jquery_register' );
function true_jquery_register() {
  if ( !is_admin() ) {
    wp_deregister_script( 'jquery' );
    wp_register_script( 'jquery', get_template_directory_uri() . '/js/jquery.min.js', [], $version);
    wp_enqueue_script( 'jquery' );
  }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Zolin, 2021-11-09
@artzolin

All scripts should be connected on the hook wp_enqueue_scripts, not oninit

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question