admin管理员组文章数量:1317898
I want to use blah/myscript/?year=2020 But this causes a 404 (and yet the page loads). However, it seems as though trying to serve a download is borked, because of the year parameter. Is there a way to disable wp's grip on this simple word?
I want to use blah/myscript/?year=2020 But this causes a 404 (and yet the page loads). However, it seems as though trying to serve a download is borked, because of the year parameter. Is there a way to disable wp's grip on this simple word?
Share Improve this question asked Oct 27, 2020 at 0:36 Doug CassidyDoug Cassidy 5787 silver badges17 bronze badges 01 Answer
Reset to default 2No.
You could try to remove year
from the whitelist of query variables, but this would cripple date archives, break all date based filtering in WP Admin, as well as break any plugins or themes that rely on this functionality. This doesn't just impact user interface, but any date based query internally
E.g. sitemaps in core would break, year based RSS and REST API requests, as would all the admin dropdown filters, calendar widgets, and any time based logic in recent posts queries, etc.
Suffice to say the damage could be significant
These are not just URL variables, query variables run much much deeper and are the keys to parameters in WP_Query
, hence the name. They're the key component that makes rewrite rules work. When you visit example/2019
it gets mapped on to index.php?year=2019
which becomes WP_Query( [ 'year' => 2019, ... ] )
, etc As far as WordPress is concerned, /2019
/index.php?year=2019
and /?year=2019
are all exactly the same
As for removing that query var, it might be necessary to fork WordPress to do it. This is one of those situations where saving yourself 5 minutes could involve 5+ years of effort, it is not a profitable trade.
Have you considered renaming your variable instead? Perhaps archive_date
or filter_date
?
本文标签:
版权声明:本文标题:Wordpress has a list of reserved words, can I override them, to use one in a query string? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742034860a2417152.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论