如何使用 WordPress 在 URL 中传递额外的变量 [英] How to pass extra variables in URL with WordPress
问题描述
我在尝试将 url 中的额外变量传递给我的 WordPress 安装时遇到问题.
I am having trouble trying to pass an extra variable in the url to my WordPress installation.
例如/news?c=123
出于某种原因,它仅适用于网站根目录 www.example.com?c=123
但如果 url 包含更多信息 www.example.com,则它不起作用/news?c=123
.我在主题目录下的functions.php文件中有以下代码.
For some reason, it works only on the website root www.example.com?c=123
but it does not work if the url contains any more information www.example.com/news?c=123
. I have the following code in my functions.php file in the theme directory.
if (isset($_GET['c']))
{
setcookie("cCookie", $_GET['c']);
}
if (isset($_SERVER['HTTP_REFERER']))
{
setcookie("rCookie", $_SERVER['HTTP_REFERER']);
}
有什么想法吗?
推荐答案
解决这个问题的解决方案很少.首先,您可以根据需要选择插件:
There are quite few solutions to tackle this issue. First you can go for a plugin if you want:
或者手动编码,查看这篇文章:
Or code manually, check out this post:
还可以查看:
这篇关于如何使用 WordPress 在 URL 中传递额外的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!