How to set up rewrite rules in WordPress to handle the following URL: "https://mywebsite.com/product-detail/model=MH-TOOL-152&isToolId=1"
This is the scan QR code The redirect link after. I should get the value of the parameter model
as this is the base of the product SKU and put my shortcode under the product details page.
I tried this below and it redirected me to the homepage. I'm trying to set it up to only show on product detail pages.
function mywebsite_rewrite_rule() { add_rewrite_rule('^product-detail/([^/]*)/?', 'index.php/model=$matches[1]', 'top'); } add_action('init', 'mywebsite_rewrite_rule', 10, 0);
I've figured out how to use rewrite rules in WP. This is what I've been doing.
Then use
get_query_var
to retrieve the model