Answer the question
In order to leave comments, you need to log in
Why don't js and jquery connect on other pages?
Scripts work, but only on the main page. There are no errors in the console, the hook catches the connection, and it simply does not appear on other pages. What could be the problem? The code from funtions.php is the first piece, the second is the code of the page where the connection should be. By the way, styles on other pages are also not included without php echo esc_url( get_stylesheet_directory_uri()
<?php
add_action('wp_enqueue_scripts', 'add_scripts_and_styles');
function add_scripts_and_styles() {
wp_deregister_script( 'jquery' );
wp_register_script('jquery','//ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js',
false, null, true);
wp_enqueue_script('jquery');
wp_enqueue_script('slick', get_template_directory_uri() . '/assets/js/slick.min.js', array ('jquery'), null, true);
wp_enqueue_script('main', get_template_directory_uri() . '/assets/js/main.js', array ('slick'), null, true);
wp_enqueue_style('mainstyle', get_stylesheet_uri());
}
?>
<?php
/*
Template Name: Оборудование
*/
?>
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="format-detection" content="telephone=no">
<link href="https://fonts.googleapis.com/css2?family=Rubik:[email protected];400;500;700;900&family=Ubuntu:[email protected];1&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="<?php echo esc_url( get_stylesheet_directory_uri() ); ?>/style.css" />
<title>Оборудование</title>
</head>
<body>
<div class="wrapper">
<?php get_header('full'); ?>
<main class="gear">
</main>
<?php get_footer(); ?>
Answer the question
In order to leave comments, you need to log in
To work correctly, the page must have the wp_head()
and functions wp_footer()
. It’s better to look at how standard or popular themes are arranged so as not to engage in amateur performances
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question