php WP删除查询字符串

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php WP删除查询字符串相关的知识,希望对你有一定的参考价值。


Important: Editing the source code of a WordPress theme could break your site if not done correctly. If you aren’t comfortable doing this, please check with a developer first. Or, you could also take advantage of the free Code Snippets plugin. This plugin will allow you to add the above code without having to worry if it will take your site down.

Simply create a new snippet and add the above code. Select “Only run on site front-end” and then save the snippet. Your query strings will then be gone! You might need to clear the cache on your WordPress site to see the changes take effect on the front-end.

Struggling with downtime and WordPress problems? Kinsta is the hosting solution designed to save you time! Check out our features
Remove query strings code snippet
Remove query strings code snippet

With Query Strings (Before Code)
Here is an example of scripts loading with query strings.

Requests with query strings
Requests with query strings

Without Query Strings (After Code)
Here is an example of scripts after having removed query strings.

Requests without query strings
Requests without query strings

2. Remove Query String from Static Resources with a Plugin
An alternative to using code is to use a WordPress performance plugin that has this feature built in. The premium Perfmatters plugin (developed by a team member at Kinsta), allows you to remove query strings from static resources with a click of a button. It also enables you to easily implement other optimizations for your WordPress site, and works alongside your current caching plugin.

Remove query strings with Perfmatters plugin
Remove query strings with Perfmatters plugin

No More Query Strings
After using either of the above options you should no longer see a warning about query strings in website speed test tools such as GTMetrix or Pingdom.

Fixed remove query strings from static resources warning
Fixed remove query strings from static resources warning

290
Shares

以上是关于php WP删除查询字符串的主要内容,如果未能解决你的问题,请参考以下文章

如何删除索引 .php 上的 wp_login?

php 删除主题的WP版本

php 删除WP默认端点

php 微小的mce wp删除属性

php 删除wp版本

php WP删除表情符号代码