Make a query variable public


In case you are messing with custom rewrite rules in WordPress and especially creating new ones with the generate_rewrite_rules hook, you should know how to make a private (or a custom, which is by default – non-public) query variable public in order to have it working correctly in the rewrite rule.

It’s actually pretty simple – you just need to add a new element in the array, that is filtered by the query_vars filter. Like so:

That’s all.

Spread the love

Leave a Reply

Your email address will not be published. Required fields are marked *