1
$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 is the url of directory.

goto
  • 7,908
  • 10
  • 48
  • 58
Shivam Shukla
  • 93
  • 1
  • 3
  • 9

2 Answers2

1

You have to pass it to the function:

$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' );

or declare it 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' );
Community
  • 1
  • 1
Niv Asraf
  • 267
  • 1
  • 10
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/

You should pass an array as $deps argument first, before $vers argument.

Haotian Liu
  • 886
  • 5
  • 19