How to remove query string from WordPress URL and Why you should? – SEO

Lets do a quick check of your WordPress source code. Right click on your WordPress article page and click view source. If you carefully see HTML source code, you will notice that few javascripts and style sheets are taking query string arguments. These query strings mostly denote the version of your WordPress or plugin that you are using. Here’s an example of one such javascript and stylesheet.

http://websitename.com/somejavascript.js?ver=3.4.2

http://websitename.com/somestyle.css?ver=3.4.2

These query string does not do any good; Firstly, the hackers can make use of this version information and secondly, it affects your SEO. Let me explain the later part a bit more; URLs that has query strings are not cached by some proxy caching servers including CDNs. Removing query strings from these resources will allow proxy caching and it can boost your website’s performance.

OK! If you are using WordPress, then follow this quick tip to remove query strings from resource URLs.

Wordpress seo

WordPress seo

How to remove query strings from WordPress resource URLs?

Open functions.php file located in your theme directory and paste the below code.

function _remove_script_version( $src ){
    $parts = explode( '?ver', $src );
        return $parts[0];
}
add_filter( 'script_loader_src', '_remove_script_version', 15, 1 );
add_filter( 'style_loader_src', '_remove_script_version', 15, 1 );

That’s it! Reload your WordPress page.

Note: Removing the query strings from your resource URLs will not affect their functionality.

Now Read: How to remove unnecessary meta tags and data from WordPress pages?

Topics :

vps germany

Get Free Email Updates

Disclaimer: The content published in this article is the views of the author only. Techglimpse does not gurantee accuracy, completness or validity. If you believe the content on this post violates your copyright, please send us a mail for removal. Read more.