Codex

Function Reference/wp register style

Contents

Description

A safe way to register a CSS style file for later use with wp_enqueue_style().

Usage

<?php wp_register_style$handle$src$deps$ver$media ?> Use the wp_print_styles action to call this function. Calling it outside of an action can lead to problems. See #17916 for details.

Parameters

$handle
(string) (required) Name of the stylesheet (which should be unique as it is used to identify the script in the whole system).
Default: None
$src
(string|boolean) (optional) URL to the stylesheet. Example: 'http://example.com/css/mystyle.css'. 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
$deps
(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()
$ver
(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
$media
(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: false

Return Values

(void) 
This function does not return a value.

Examples

Notes

  • See WP_Styles::add() For parameter and additional information.
  • Uses global: (object) $wp_styles

Change Log

  • Since: 2.1 (BackPress version: r79)

Source File

wp_register_style() is located in wp-includes/functions.wp-styles.php.

Related

wp_register_style(), wp_deregister_style(), wp_enqueue_style(), wp_dequeue_style()

See also index of Function Reference and index of Template Tags.