Home / Attachments / Remove Query Strings From Static Files (exclude login)
Duplicate Snippet

Embed Snippet on Your Site

Remove Query Strings From Static Files (exclude login)

This is a copy of the regular query strings exclude snippet that also adds a check to prevent the snippet from running on the login page.

<10
Code Preview
php
<?php
function wpcode_snippet_remove_query_strings_split_login( $src ) {
	$output = preg_split( "/(&ver|?ver)/", $src );
	return $output ? $output[0] : '';
}
add_action( 'init', function () {
	if ( ! is_admin() && ! is_login() ) {
		add_filter( 'script_loader_src', 'wpcode_snippet_remove_query_strings_split_login', 15 );
		add_filter( 'style_loader_src', 'wpcode_snippet_remove_query_strings_split_login', 15 );
	}
} );

Comments

Add a Comment