$custom_style = 'css/pre/custom-styles.css';
function custom_stylesheet() {
wp_enqueue_style( 'aps-custom-style', APS_URL .$custom_style, APS_VER );
}
add_action( 'wp_enqueue_scripts', 'custom_stylesheet' );
APS_URL是目录的网址。
答案 0 :(得分:1)
您必须将其传递给函数:
$custom_style = 'css/pre/custom-styles.css';
function custom_stylesheet($custom_style) {
wp_enqueue_style( 'aps-custom-style', APS_URL .$custom_style, APS_VER );
}
add_action( 'wp_enqueue_scripts', 'custom_stylesheet' );
或声明global:
$custom_style = 'css/pre/custom-styles.css';
function custom_stylesheet() {
global $custom_style;
wp_enqueue_style( 'aps-custom-style', APS_URL .$custom_style, APS_VER );
}
add_action( 'wp_enqueue_scripts', 'custom_stylesheet' );
答案 1 :(得分:1)
wp_enqueue_style( string $handle, string $src = '', array $deps = array(), string|bool|null $ver = false, string $media = 'all' )
https://developer.wordpress.org/reference/functions/wp_enqueue_style/
在$ vers参数之前,你应首先将数组作为$ deps参数传递。