functions.php
/**
* Подключения по умолчанию scripts and styles.
*/
function watch2_scripts() {
wp_enqueue_style( 'watch2-style', get_stylesheet_uri() );
wp_enqueue_script( 'watch2-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true );
wp_enqueue_script( 'watch2-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'watch2_scripts' );
Динамически через ф-цю wp_head() (вставлять в <head>) генерирует подключения css и js.
wp_enqueue_style( 'watch2-style', get_stylesheet_uri() ); - генерирует html запись://id, style.css в корне(без пути)
<link rel='stylesheet' id='watch2-style-css' href='http://wp.my-tamagochi.ru/wp-content/themes/watch2/style.css?ver=5.0.3' type='text/css' media='all' />
генерирует подключение style.css по умолчанию.
Подключение JS.
wp_enqueue_script( 'watch2-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true );
генерирует HTML:
<script type='text/javascript' src='http://wp.my-tamagochi.ru/wp-content/themes/watch2/js/navigation.js?ver=20151215'></script>
где watch2-navigation хз че такое
get_template_directory_uri() - путь
array() - х-ня для переопределения стилей или скриптов. Если не переопределяем то пустой.
'20151215' - произв число для хеша. Можно поставить генератор js или php
true - генерировать js в футере, false - в хедере.