apply_filters( ‘stylesheet_uri’, string $stylesheet_uri, string $stylesheet_dir_uri )

Filters the URI of the active theme stylesheet.

Parameters

$stylesheet_uristring
Stylesheet URI for the active theme/child theme.
$stylesheet_dir_uristring
Stylesheet directory URI for the active theme/child theme.

Source

return apply_filters( 'stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri );

Changelog

VersionDescription
1.5.0Introduced.

User Contributed Notes

  1. Skip to note 2 content

    Use a custom stylesheet for single posts.

    /**
     * Use a custom stylesheet for single posts.
     *
     * @param string $stylesheet     Original stylesheet URI.
     * @param string $stylesheet_dir Stylesheet directory.
     * @return string (Maybe modified) stylesheet URI.
     */
    function wpdocs_custom_stylesheet_for_single_posts( $stylesheet, $stylesheet_dir ) {
    
    	if ( is_singular( 'post' ) ) {
    		$stylesheet = $stylesheet_dir . '/custom-single.css';
    	}
    
    	return $stylesheet;
    }
    add_filter( 'stylesheet_uri', 'wpdocs_custom_stylesheet_for_single_posts', 10, 2 );

You must log in before being able to contribute a note or feedback.