Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在Wordpress子主题中加载CSS文件';是否嵌套在不同的文件夹和名称中?_Php_Css_Wordpress_Themes - Fatal编程技术网

Php 如何在Wordpress子主题中加载CSS文件';是否嵌套在不同的文件夹和名称中?

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_

这可能很容易,但我只是想确保我做得正确。基本上,我已经使用子主题制作了一堆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_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' );
正如您所说,使用路径时,路径将始终指向父主题文件夹。如果适用,用于指向当前/子主题文件夹