最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to ignore GET parameter that’s the same as a CPT slug?

programmeradmin2浏览0评论

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 badges
Add a comment  | 

1 Answer 1

Reset to default 0

You 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.

发布评论

评论列表(0)

  1. 暂无评论