I have a WP page, suppose it is mydomain.com/some-page/
The page accepts a param in its querystring that corresponds to a specific product (there is a product for each days). So suppose today’s product is 38438, tomorrow’s is 38439, etc.
In that case today’s link would be mydomain.com/some-page/?prd=38438, tomorrow’s would be mydomain.com/some-page/?prd=38439, etc.
So, there are two scenarios:
- When the user visits mydomain.com/some-page/ it should automatically redirect them to today’s link (mydomain.com/some-page/?prd=38438)
- When the user visits mydomain.com/some-page/?prd=99999, it should check whether 99999 corresponds to an existing product
- If yes, then it should open the page normally
- If no, then it should redirect them to today’s product page (mydomain.com/some-page/?prd=38438)
I know how to perform all those checks in regard to the existence of products, etc. I just don’t know what’s the appropriate hook to use that would take the current URL and analyze it, in order to determine whether it’d redirect the user on not based on the above rules.
Can someone point me to the correct hook to use?