I have 2 pages and each of them has its own cap. 2 different caps I can call using <?php get_header('2'); ?> <?php get_header('2'); ?> and I will call header-2.php in this way. And inside this file in the tag I call <?php wp_head(); ?> <?php wp_head(); ?> . And he uploads styles for header.php . That's what I have in function.php

 function elkino_scripts() { wp_enqueue_style( 'style', get_template_directory_uri() . '/css/style.css' ); wp_enqueue_script( 'header', get_template_directory_uri() . '/js/header.js', array(), null, true ); wp_enqueue_script( 'yandex-map-api', 'https://api-maps.yandex.ru/2.1/?lang=ru_RU', array(), null, true ); wp_enqueue_script( 'util-calculate-area-min', get_template_directory_uri() . '/js/util.calculateArea.min.js', array(), null, true ); wp_enqueue_script( 'polylabel-min', get_template_directory_uri() . '/js/polylabel.min.js', array(), null, true ); wp_enqueue_script( 'newmap', get_template_directory_uri() . '/js/newmap.js', array(), null, true ); } add_action( 'wp_enqueue_scripts', 'elkino_scripts' ); 

So that is what I actually can not figure out. How do I make it so that in two different files header.php and header-1.php, different css and js files are loaded.

Ps I was looking for an example on the Internet, but it showed how to connect different headers and that's it. I would be very happy if you can show by example how this should be implemented.

  • Why different css-files? IMHO it is better to rename the classes in the second header. And set them in general. Or separately connected. Additionally. rather than "instead." Similarly with js. - SeVlad 3:49 pm
  • Then extra css and js code will be loaded, which will slow down the page loading speed. Why load a code that will not be used? Oo - olishevskyalex
  • Do not save on matches, so no one does. Css in 10 thousand lines is ok. @SeVlad says the right thing - KAGG Design
  • If you really want to, then you need to understand that the styles are loaded not for header.php, but for the site as a whole. You need to insert is_page () -based logic into elkino_scripts - KAGG Design
  • one
    First, sss and js are cached by the browser. Secondly, the extra code will be just when different files will work. - SeVlad

0