wp_print_styles() WordPress Function

wp_print_styles() is a function that allows you to enqueue or register stylesheets on your WordPress site. This function is typically called in the header.php file of your theme.

wp_print_styles( string|bool|array $handles = false ) #

Display styles that are in the $handles queue.


Description

Passing an empty array to $handles prints the queue, passing an array with one string prints that style, and passing an array of strings prints those styles.


Top ↑

Parameters

$handles

(string|bool|array)(Optional)Styles to be printed. Default 'false'.

Default value: false


Top ↑

Return

(string[]) On success, an array of handles of processed WP_Dependencies items; otherwise, an empty array.


Top ↑

Source

File: wp-includes/functions.wp-styles.php

function wp_print_styles( $handles = false ) {
	global $wp_styles;

	if ( '' === $handles ) { // For 'wp_head'.
		$handles = false;
	}

	if ( ! $handles ) {
		/**
		 * Fires before styles in the $handles queue are printed.
		 *
		 * @since 2.6.0
		 */
		do_action( 'wp_print_styles' );
	}

	_wp_scripts_maybe_doing_it_wrong( __FUNCTION__ );

	if ( ! ( $wp_styles instanceof WP_Styles ) ) {
		if ( ! $handles ) {
			return array(); // No need to instantiate if nothing is there.
		}
	}

	return wp_styles()->do_items( $handles );
}


Top ↑

Changelog

Changelog
VersionDescription
2.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.