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

本文标签: How to ignore GET parameter that’s the same as a CPT slug