How to insert CSS stylesheet using enqueue
-
[ Moved to the Fixing WordPress sub-forum. ]
I am very new to wp and I would like to insert some CSS into just one page using the style register and style enqueue method. Right now it works fine when the CSS is in my footer but I would like to do it the preferred way. This is my code:
#sig
{
color:#00ff00;
background-color:#000000;
width:82px;
border:6px solid powderblue;
}and here are all my questions:
1. I would create a file with name: my_stylesheet.CSS and put it in a new folder in my root directory (my wp sits in C:\xampp\htdocs\WP). That would be C:\xampp\htdocs\WP\my.CSS (Am I right?)
2. would my $handle be my_stylesheet.CSS ?
3. would I than go into functions.wp-styles.php in WP subdirectory wp-includes and open it, and go to the following code:function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media = 'all' ) {
_wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );return wp_styles()->add( $handle, $src, $deps, $ver, $media );
}Here I would copy the above function but change $handle to ‘my_stylesheet.CSS’,
and change $src to ‘\my.CSS\my_stylesheet.CSS’,,,)After registering I would do same thing using function wp_enqueue_style()
4. Last thing would be to add the code:
add_action(‘my_stylesheet.CSS’,’\my.CSS\my_stylesheet.CSS’)These are “detail” that I am not sure off. I might also be completely off.
Please, help.
Vlad
- The topic ‘How to insert CSS stylesheet using enqueue’ is closed to new replies.