Home Wordpress Enqueue a custom stylesheet in WordPress

Enqueue a custom stylesheet in WordPress

Author

Date

Category

To enqueue a custom stylesheet in WordPress, you would use the wp_enqueue_style() function. For example, the following code would enqueue a custom stylesheet called “custom.css” in your theme directory:

function enqueue_custom_stylesheet() {
  wp_enqueue_style( 'custom-style', get_template_directory_uri() . '/custom.css' );
}
add_action( 'wp_enqueue_scripts', 'enqueue_custom_stylesheet' );
PHP


This code would add the custom stylesheet to the list of stylesheets that are loaded on your WordPress site.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Subhash Shipu

PHP Expert

Hey there! I'm a PHP geek on a mission to blog my way through the coding chaos. When I'm not chasing semicolons, I'm busy cuddling my pet Coco, who thinks debugging means chasing her own tail. Join the fun!

Subscribe

Recent posts