Clean URL with url parameters
-
Hi all,
I have a website and I want to expand it with a product catalogus (category and productdetail pages). I’ve build it with php and when a visitor clicks on a product in the category view, a few parameters passes through the url. So for example I have:
Category page (www.domain.com/washingmachine)
–miele w3203
–bosch 232323
–aeg zzaadd21
–etcAnd when a visitor click on the miele w3203 the url is:
https://www.domain.com/detail?cat=wasmachingmachine&idnummer=658The productdetail page is a seperate template page. This works, only the url is very bad. I want to like this:
https://www.domain.com/washingmachine/miele-w3203I use a custom MySQL query on the productdetail page where I need the category and id of the clicked product.
global $wpdb; $databasetabel = $_GET['cat']; $idnummer = $_GET['idnummer']; $data = $wpdb->get_results(" SELECT * FROM $databasetabel WHERE idnummer=".$idnummer." LIMIT 0, 100; ");
I really want to use the WordPress add_query_vars but I’ve tried all day and I can’t figure it out. How can I get the url I want and what is best practice here? How can I pass parameters from a category page to a detailpage without placing them in the url? Or do I need a rewrite? Really confused here!
Thanks so much for helping me out!!!
Kind regards,
Mark
- The topic ‘Clean URL with url parameters’ is closed to new replies.