I need to do two things:
- Add a CGI variable (say filter=21) to the current query and make a link to this modified URL.
- Fetch the value of CGI variable "filter".
How to do that in WordPress?
First off, these aren't CGI variables, they're query string arguments.
WordPress, by default, will remove any query arguments that it doesn't recognize. So you need to register them with WordPress and then pull them back out of the query.
First, add your new query variable:
Now, get the data back out: