admin管理员组文章数量:1396440
I have a custom post type called newsletter. At the same time, an implemented analytics tool (not related to my CPT) uses newsletter as a GET parameter to track some incoming links (and I can’t change this).
Say, I have
/?newsletter=value_for_analytics_tool
This will lead to an 404 error page, as WordPress obviously tries to find a post in my newsletter CPT. But actually, I just want the main page to show up and keep the newsletter parameter for the analytics tool.
Is there any way to 'ignore' GET parameters, but keep my CPT working?
I have a custom post type called newsletter. At the same time, an implemented analytics tool (not related to my CPT) uses newsletter as a GET parameter to track some incoming links (and I can’t change this).
Say, I have
https://www.example/?newsletter=value_for_analytics_tool
This will lead to an 404 error page, as WordPress obviously tries to find a post in my newsletter CPT. But actually, I just want the main page to show up and keep the newsletter parameter for the analytics tool.
Is there any way to 'ignore' GET parameters, but keep my CPT working?
Share Improve this question asked Jan 29, 2020 at 13:52 mischnumischnu 115 bronze badges1 Answer
Reset to default 0You should always preface your CPT names with something to avoid stuff like this - common naming leads to conflicts. My recommendation, so that you avoid this happening again would be to go and re-work your CPT code in your plugin/theme and use myplug_newsletter
as the name of your CPT. Obviously change the myplug_ to something unique to you.
本文标签: How to ignore GET parameter that’s the same as a CPT slug
版权声明:本文标题:How to ignore GET parameter that’s the same as a CPT slug? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744792861a2625397.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论