wp_enqueue_style()

Використання

wp_enqueue_style( $handle, $src, $deps, $ver, $media );

Parameters

  • $handle: (string) Required
    Name of the stylesheet. Should be unique.
  • $src: (string) Required
    Full URL of the stylesheet, or path of the stylesheet relative to the WordPress root directory.
    Default Value: ”
  • $deps: (string) Optional
    An array of registered stylesheet handles this stylesheet depends on.
    Default Value: array()
  • ver: (string | bool | null) Optional
    String specifying stylesheet version number, if it has one, which is added to the URL as a query string for cache busting purposes. If version is set to false, a version number is automatically added equal to current installed WordPress version. If set to null, no version is added.
    Default Value: false
  • $media: (string) Optional
    The media for which this stylesheet has been defined.Accepts media types like ‘all’, ‘print’ and ‘screen’, or media queries like ‘(orientation: portrait)’ and ‘(max-width: 640px)’.
    Default Value: ‘all’
/**
 * Правильний спосіб підключити стилі та скріпти
 */
function theme_name_scripts() {
	wp_enqueue_style( 'style-name', get_stylesheet_uri() );
	wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true );
}
add_action( 'wp_enqueue_scripts', 'theme_name_scripts' );
Disclaimer: Наразі шаблон сторінки трошки поламаний, скоро пофікшу. І давай будемо на "ти". Якщо ти дочитав до цього моменту і не знайшов те, що шукав в описі саме цієї функції - напиши мені в телеграм @codelibry щоб я це додав, а також скинь лінк того що саме ти шукав, якщо знайшов на іншому ресурсі. Дякую :)