Php 如何在Wordpress子主题中加载CSS文件';是否嵌套在不同的文件夹和名称中?
这可能很容易,但我只是想确保我做得正确。基本上,我已经使用子主题制作了一堆Wordpress站点,通常style.css位于主题的根文件夹中,我在functions.php文件中使用了这个Php 如何在Wordpress子主题中加载CSS文件';是否嵌套在不同的文件夹和名称中?,php,css,wordpress,themes,Php,Css,Wordpress,Themes,这可能很容易,但我只是想确保我做得正确。基本上,我已经使用子主题制作了一堆Wordpress站点,通常style.css位于主题的根文件夹中,我在functions.php文件中使用了这个 <?php add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); function theme_enqueue_styles() { wp_enqueue_style( 'parent-style', get_template_
<?php
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
要在子主题中添加样式表,有两个选项/行为:
// This will point to style.css in child theme
wp_enqueue_style( 'my_child_styles', get_stylesheet_directory_uri().'/style.css' );
// This will point to style.css in the parent theme
wp_enqueue_style( 'my_parent_styles', get_template_directory_uri().'/style.css' );
正如您所说,使用路径时,路径将始终指向父主题文件夹。如果适用,用于指向当前/子主题文件夹