apply_filters( 'stylesheet_uri', string $stylesheet_uri, string $stylesheet_dir_uri )

Filters the URI of the current theme stylesheet.


Description Description


Parameters Parameters

$stylesheet_uri

(string) Stylesheet URI for the current theme/child theme.

$stylesheet_dir_uri

(string) Stylesheet directory URI for the current theme/child theme.


Top ↑

Source Source

File: wp-includes/theme.php

View on Trac


Top ↑

Changelog Changelog

Changelog
Version Description
1.5.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 1 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.