Здравствуйте, у меня не подключаются стили. У меня задание - сделать шаблон для wordpress, все вроде работает, но когда дело доходит до стилей, они не подключаются, хотя делаю все, что говорит wordpress. Я решила подключить стили через папку function.php Вот коды: <b>function.php</b> PHP: <?php function shablonforwordpress1(){ // Регистрирую стили wp_register_style( 'my_reset', get_template_directory_uri() . 'assets/css/reset.min.css', array(), '1.2', 'screen'); wp_register_style( 'my_style', get_template_directory_uri() . 'assets/css/style.css', array('my_reset'), '1.47', 'screen'); // Подключаю стили wp_enqueue_style( 'my_reset'); wp_enqueue_style( 'my_style'); // Подключать стили можно и сразу, без регистрации. Тогда необходимо прописать все параметры внутри wp_enqueue_style(); // Пример подключение стандартного обязательного файла стилей style.css wp_enqueue_style( 'shablonforwordpress1', get_stylesheet_uri() ); // Создаем экшн в котором подключаем скрипты подключенные внутри функции twentytwelve_scripts_styles add_action( 'wp_enqueue_scripts', 'shablonforwordpress1', 1 ); <b>header.php </b> PHP: <!DOCTYPE HTML> <html lang="en"> <head> <meta charset="UTF-8"> <meta name ="viewport" content = "width=device-width, initial-scale=1.0"> <meta http-equiv = "X-UA-Compatible" content = "ie-edge"> <link href = "https://fonts.googleapis.com/css?family=Lato:300,700|Roboto:300,400,700&display=swap&subset=cyrillic" rel = "stylesheet"> <title></title> <?php wp_head();?> </head> <body background="C:\Users\TheNay\макетдляWordPress\assets\images\Слой3.png"> <header class = "header"> <div id = "block1"> <div class = "header_ss"> link for the site to the organization </div> <div class="logo_picture"> <img src="C:\Users\TheNay\макетдляWordPress\assets\images\health-304919_960_720.png"> </div> <?php get_footer();?> <div class = "logo"> We help people </div> </div> <div class = "header_logo"> <figure><img src="C:\Users\TheNay\макетдляWordPress\assets\images\1.jpg"></figure> </div> </header> <b> style.css</b> PHP: /* Theme Name: shablonforwordpress1 */ *{ margin: 0; padding: 0; } body{ background-size: cover; background-repeat:no-repeat; background-position: absolute; } .header_logo img{ background-repeat: no-repeat; background-position: center; margin-top: 140px; height: 760px; width:100%; background-size: cover; padding: 0; margin: 0; } .logo{ font-size:70px; color: aliceblue; position: absolute; margin-left: 30px; top: 25px; } .logo_picture img{ background-size: cover; background-position: center center; height: 120px; width: 120px; margin-left: 540px; top: 8px; position: absolute; } .header_panel p { word-spacing: 10px; font-size:25px; color:white; position: absolute; margin-right:30px; top: 75px; left:760px; } .header_ss { font-size: 30px; margin-left: 760px; top: 30px; position: absolute; } .header_ss2{ font-size:40px; position: absolute; color: white; top: 925px; left: 340px; } .logo_picture2 img{ background-size: cover; position: absolute; height: 450px; left: 495px; margin-top: 75px; } .logo3{ font-size: 80px; font-weight: bold; margin-left: 75px; position: absolute; margin-top: 80px; } .text{ position: absolute; font-size: 30px; margin-top: 200px; margin-left: 40px; } .Button img{ position: absolute; background-size: cover; height: 75px; margin-top: 400px ; margin-left: 75px; } .Podrobno{ font-weight: bold; color: teal; font-size: 40px; margin-top: 407px; margin-left: 150px; position: absolute; } .logo_picture3 img{ background-size: cover; position: absolute; height: 450px; left: 100px; margin-top: 75px; } .logo4{ font-size: 80px; font-weight: bold; margin-left: 800px; position: absolute; margin-top: 80px; } .text2{ position: absolute; font-size: 30px; margin-top: 200px; margin-left: 770px; } .Button2 img{ position: absolute; background-size: cover; height: 75px; margin-top: 400px; margin-left: 800px; } .Podrobno2{ font-weight: bold; color: teal; font-size: 40px; margin-top: 407px; margin-left: 875px; position: absolute; } .logo_picture4 img{ background-size: cover; position: absolute; height: 450px; left: 430px; margin-top: 75px; } .logo5{ font-size: 80px; font-weight: bold; margin-left: 60px; position: absolute; margin-top: 80px; } .text3{ position: absolute; font-size: 30px; margin-top: 200px; margin-left: 40px; } .Button3 img{ position: absolute; background-size: cover; height: 75px; margin-top: 400px ; margin-left: 50px; } .Podrobno3{ font-weight: bold; color: teal; font-size: 40px; margin-top: 407px; margin-left: 127px; position: absolute; } .text_os{ color: #033; font-size: 80px; text-align: center; margin-top: 200px; } .text_info{ color: white; font-size: 35px; margin-left: 550px; margin-top: 40px; position: absolute; } .social_net1 img{ position: absolute; background-size: cover; height: 90px; margin-left: 660px; margin-top: 150px; } .social_net2 img{ position: absolute; background-size: cover; height: 90px; margin-left: 780px; margin-top: 150px; } .social_net3 img{ position: absolute; background-size: cover; height: 90px; margin-left: 900px; margin-top: 150px; } .number{ color: white; font-size: 50px; position: absolute; margin-top: 120px; margin-left: 40px; } .telephone_hot{ color: aquamarine; font-size: 30px; position: absolute; margin-top: 80px; margin-left: 79px; }
Когда в именах ф-ций, констант и т.п. используется слово directory, то у значения скорее всего нет завершающего слеша Посмотрите на полученные адреса в коде страниц и сразу все поймете.
Блин, не работает( PHP: <?php function shablonforwordpress1(){ // Регистрирую стили wp_register_style( 'my_reset', get_template_directory_uri() . '/assets/css/reset.min.css', array(), '1.2', 'screen'); wp_register_style( 'my_style', get_template_directory_uri() . '/assets/css/style.css', array('my_reset'), '1.47', 'screen'); // Подключаю стили wp_enqueue_style( 'my_reset'); wp_enqueue_style( 'my_style'); // Подключать стили можно и сразу, без регистрации. Тогда необходимо прописать все параметры внутри wp_enqueue_style(); // Пример подключение стандартного обязательного файла стилей style.css wp_enqueue_style( 'shablonforwordpress1', get_stylesheet_uri() ); // Создаем экшн в котором подключаем скрипты подключенные внутри функции twentytwelve_scripts_styles add_action( 'wp_enqueue_scripts', 'shablonforwordpress1', 1 );