apply_filters( 'style_loader_src', string $src, string $handle )

Filters an enqueued style’s fully-qualified URL.


Parameters Parameters

$src

(string) The source URL of the enqueued style.

$handle

(string) The style's registered handle.


Top ↑

Source Source

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

View on Trac



Top ↑

Changelog Changelog

Changelog
Version Description
2.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note 2 content
    Contributed by Anthony Hortin

    If you have a child theme that has had its stylesheet enqueued from within the main Parent theme, and you wish to update the version number that’s appended to the url, you can include this in your child theme functions.php file.

    Obviously, change the version number (‘6.0.0’ in this example) to whatever is appropriate for you, along with comparing the approriate stylesheet handle (‘wpdocs-style’ in this example)

    Where:
    $src – (string) The source URL of the enqueued style
    $handle – (string) The style’s registered handle

    /**
     * Update the version number on our child theme stylesheet, that's been enqueued from within the parent theme
     */
    function wpdocs_update_stylesheet_version( $src, $handle ) {
    	if ( ! strcmp( $handle, 'wpdocs-style' ) ) {
    		$src = get_stylesheet_uri();
    		$src = add_query_arg( 'ver', '6.0.0', $src );
    	}
    	return $src;
    }
    add_filter( 'style_loader_src', 'wpdocs_update_stylesheet_version', 10, 2 );
    

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