{"id":2188,"date":"2015-07-25T05:01:54","date_gmt":"2015-07-25T05:01:54","guid":{"rendered":"https:\/\/freelancer-coder.com\/?p=2188"},"modified":"2025-03-17T16:02:37","modified_gmt":"2025-03-17T10:32:37","slug":"remove-query-string-wordpress","status":"publish","type":"post","link":"https:\/\/freelancer-coder.com\/remove-query-string-wordpress\/","title":{"rendered":"How to remove query string from static resource in wordpress"},"content":{"rendered":"<p>Before getting a look on how to remove query string from static resources, lets see what is query string.<\/p>\n<h2>What is query string?<\/h2>\n<p>It is a part of a URL(Uniform Resource Locator) containing some data that does not fit conveniently into a hierarchical path structure. The query string commonly includes fields added to a base URI by a Web browser or other client application after domain name.<\/p>\n<p>It is added to static resources like JS or CSS can cause some problems in getting higher rank.<\/p>\n<h2>Benefits:<\/h2>\n<ul>\n<li>Improve cache performance<\/li>\n<li>Better rank in Google search results<\/li>\n<li>Google PageSpeed improvements<\/li>\n<li>Higher speed in YSlow test results<\/li>\n<li>Higher speed in Pingdom and GTmetrix as well.<\/li>\n<\/ul>\n<p>Here is the simple code which can help, just place the code in functions.php in your theme.<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\/\/Add this code in theme functions.php file\n\nfunction remove_cssjs_ver($src) {\n&amp;amp;amp;amp;nbsp;&amp;amp;amp;amp;nbsp;&amp;amp;amp;amp;nbsp; if (strpos($src, &amp;#039;?ver=&amp;#039;))\n&amp;amp;amp;amp;nbsp;&amp;amp;amp;amp;nbsp;&amp;amp;amp;amp;nbsp;&amp;amp;amp;amp;nbsp;&amp;amp;amp;amp;nbsp;&amp;amp;amp;amp;nbsp;&amp;amp;amp;amp;nbsp; $src = remove_query_arg(&amp;#039;ver&amp;#039;, $src);\n&amp;amp;amp;amp;nbsp;&amp;amp;amp;amp;nbsp;&amp;amp;amp;amp;nbsp; return $src;\n}\n\nadd_filter(&amp;#039;style_loader_src&amp;#039;, &amp;#039;remove_cssjs_ver&amp;#039;, 10, 2);\nadd_filter(&amp;#039;script_loader_src&amp;#039;, &amp;#039;remove_cssjs_ver&amp;#039;, 10, 2);\n<\/pre>\n<p>Resources:<br \/>\n&#8211; <a title=\"https:\/\/codex.wordpress.org\/Function_Reference\/get_query_var\" href=\"https:\/\/codex.wordpress.org\/Function_Reference\/get_query_var\" target=\"_blank\" rel=\"noopener\">https:\/\/codex.wordpress.org\/Function_Reference\/get_query_var<\/a><br \/>\n&#8211; <a title=\"https:\/\/en.wikipedia.org\/wiki\/Query_string\" href=\"https:\/\/en.wikipedia.org\/wiki\/Query_string\" target=\"_blank\" rel=\"noopener\">https:\/\/en.wikipedia.org\/wiki\/Query_string<\/a><\/p>\n<p>I am a <strong>pro<\/strong> at troubleshooting glitches in any code of WordPress. Please feel free to <a href=\"https:\/\/freelancer-coder.com\/contact-wordpress-developer\/\">connect with me<\/a> in case if you like to ask anything related to WordPress.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Before getting a look on how to remove query string from static resources, lets see what is query string. What is query string? It is a part of a URL(Uniform Resource Locator) containing some data that does not fit conveniently into a hierarchical path structure. The query string commonly includes fields added to a base [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":9317,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[96,88,63],"tags":[195,196,62,197,198],"class_list":["post-2188","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-freebies","category-useful","category-wordpress","tag-query-string","tag-static-resources","tag-wordpress","tag-wordpress-beautify-url","tag-wordpress-remove-query-string"],"acf":[],"_links":{"self":[{"href":"https:\/\/freelancer-coder.com\/wp-json\/wp\/v2\/posts\/2188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/freelancer-coder.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/freelancer-coder.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/freelancer-coder.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/freelancer-coder.com\/wp-json\/wp\/v2\/comments?post=2188"}],"version-history":[{"count":5,"href":"https:\/\/freelancer-coder.com\/wp-json\/wp\/v2\/posts\/2188\/revisions"}],"predecessor-version":[{"id":9318,"href":"https:\/\/freelancer-coder.com\/wp-json\/wp\/v2\/posts\/2188\/revisions\/9318"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/freelancer-coder.com\/wp-json\/wp\/v2\/media\/9317"}],"wp:attachment":[{"href":"https:\/\/freelancer-coder.com\/wp-json\/wp\/v2\/media?parent=2188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/freelancer-coder.com\/wp-json\/wp\/v2\/categories?post=2188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/freelancer-coder.com\/wp-json\/wp\/v2\/tags?post=2188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}