The Daily WordPress Reference

A safe way to add/enqueue a CSS style file to the wordpress generated page. If it was first registered with wp_register_style() it can now be added using its handle.

 wp_enqueue_style( $handle, $src, $deps, $ver, $media );  
   (string) (required) Name of the stylesheet.
   Default: None
   (string|boolean) (optional) URL to the stylesheet. Example: ''.
   This parameter is only required when WordPress does not already know about this style.
   You should never hardcode URLs to local styles, use Function Reference/plugins_url (for Plugins) and Function Reference/get_template_directory_uri (for Themes) to get a proper URL.
   Default: false
   (array) (optional) Array of handles of any stylesheet that this stylesheet depends on; stylesheets that must be loaded before this stylesheet. false if there are no dependencies.
   Default: array()
   (string|boolean) (optional) String specifying the stylesheet version number, if it has one.
   This parameter is used to ensure that the correct version is sent to the client regardless of caching, and so should be included if a version number is available and makes sense for the stylesheet.
   Default: false
   (string|boolean) (optional) String specifying the media for which this stylesheet has been defined. Examples: 'all', 'screen', 'handheld', 'print'. See this list for the full range of valid CSS-media-types.
   Default: 'all'
Return values
     This function does not return a value.

Loading stylesheets in WordPress themes

function theme_styles()  
  // Register the style like this for a theme:  
  // (First the unique name for the 
  // style (custom-style) then the src, 
  // then dependencies and ver no. and media type)
  wp_register_style( 'custom-style', 
    get_template_directory_uri() . '/css/custom-style.css', 
    'all' );

  // enqueing:
  wp_enqueue_style( 'custom-style' );
add_action('wp_print_styles', 'theme_styles');
More informations

Liked this function?
You might also like these books:
Share it:
share on Twitter
Like The Daily WordPress Reference: wp_enqueue_style() on Facebook

Or Donate to this project:
Donata via Paypal
(Why Donate?)

Email Marketing Powered by Mailchimp