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.

1
  • 1
    Why do you think something is wrong? What is the error you are getting? Commented Jan 29, 2017 at 17:52

2 Answers 2

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' );
Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.