admin管理员组文章数量:1416305
I'm trying to make a child theme of the twentyseventeen theme. I started by making a style.css with the content:
/*
Theme Name: John Tries This
Template: twentyseventeen
*/
I then made this functions.php
<?php
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
$parent_style = 'parent-style'; // This is 'twentyseventeen-style' for the Twenty Seventeen theme.
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',get_stylesheet_directory_uri() . '/style.css'
// ,array( $parent_style )
);
}
What I don't understand is the 3rd argument of wp_enqueue_style. You see that I have it commented out. My web page shows all my parent styles and templates regardless of whether or not I comment out the ,array($parent_style)
.
So what exactly does this 3rd argument do? The wordpress documentation says it is a list of dependencies. Why should I provide dependencies? What behaviour will it alter?
I'm trying to make a child theme of the twentyseventeen theme. I started by making a style.css with the content:
/*
Theme Name: John Tries This
Template: twentyseventeen
*/
I then made this functions.php
<?php
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
$parent_style = 'parent-style'; // This is 'twentyseventeen-style' for the Twenty Seventeen theme.
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style',get_stylesheet_directory_uri() . '/style.css'
// ,array( $parent_style )
);
}
What I don't understand is the 3rd argument of wp_enqueue_style. You see that I have it commented out. My web page shows all my parent styles and templates regardless of whether or not I comment out the ,array($parent_style)
.
So what exactly does this 3rd argument do? The wordpress documentation says it is a list of dependencies. Why should I provide dependencies? What behaviour will it alter?
Share Improve this question asked Aug 13, 2019 at 21:08 learningtechlearningtech 1971 silver badge14 bronze badges 01 Answer
Reset to default 1The 3rd argument of wp_enqueue_style
means when enqueuing this stylesheet make sure it is after the list of dependencies.
In your case, prior to enqueueing the child-style
WordPress make sure that parent-style
is enqueued first.
Even though the enqueued statements are in the correct order:
wp_enqueue_style('parent-style', get_template_directory_uri() . '/style.css');
wp_enqueue_style('child-style', get_stylesheet_directory_uri() . '/style.css');
There will be an instance where child-style
is enqueued first before the parent-style
. So, to make sure that the order of the enqueued stylesheets are correct you need to supply the third argument, which is a list of dependencies.
本文标签: themeswpenqueuestyle dep argument does nothing
版权声明:本文标题:themes - wp_enqueue_style $dep argument does nothing? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745245036a2649517.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论