如何忽略与CPT插件相同的GET参数?

时间:2020-01-29 作者:mischnu

我有一个自定义的帖子类型,名为newsletter。同时,一个已实现的分析工具(与我的CPT无关)使用新闻稿作为GET参数来跟踪一些传入链接(我无法更改)。

说吧,我有

https://www.example.com/?newsletter=value_for_analytics_tool
这将导致404错误页面,因为WordPress显然试图在我的新闻稿CPT中找到帖子。但实际上,我只想显示主页并保留分析工具的新闻稿参数。

有没有办法“忽略”获取参数,但保持我的CPT工作?

1 个回复
SO网友:Tony Djukic

你应该总是在你的CPT名称前加上一些东西来避免这样的事情——共同的命名会导致冲突。为了避免这种情况再次发生,我的建议是在插件/主题中重新编写CPT代码并使用myplug_newsletter 作为您的CPT的名称。显然,将myplug\\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu。

相关推荐

Custom slugs for Each Tab

我有一个音乐家信息网站。这些信息通过“常规”、“歌曲”、“相册”和“视频”选项卡分为几个不同的主题。<?php if($tab_story){?> <li role=\"presentation\" class=\"active\"> <a href=\"#story\" aria-controls=\"story\" role=\"tab\" data-toggle=\"tab\">Information</a> </