How to WordPress dynamic url prefix based on taxonomy
-
I’m developing an offers site using wordpress. We are trying to offer different offers regarding the city.
So we have two taxonomies (category and city).
The thing is that I don’t want to use the normal url structure, I wish it could be:
root -> https://site .com/city-taxonomy
category -> https://site .com/city-taxonomy/category
offer -> https://site .com/city-taxonomy/offer-slugBasically I want to split my site in cities without using a multiple site (network) in wordpress so i don’t need to repeat categories or custom fields. I want to maintain the current wordpress url system how its working but adding the prefix I can read from php using GET
The if anybody manage to do this, I’d like to know how will you handle the url creating in the template, using the city as a prefix, global variable should be enoght.
I thought about creating city as category and subcategories, but I’d need to repeat all the subcategories for each one.
One offer could be included in several cities and one category.
I readed about the rewrite rules functions in wordpress php but I think it should be faster if I do this in htaccess.
The thing is that after including a rule like:
RewriteRule ^([^/]+)/? index.php?city=$1 [L]
This is always redirecting me to search functionality in wordpress, and I don’t know if this is a good long term solution.
Thanks!
- The topic ‘How to WordPress dynamic url prefix based on taxonomy’ is closed to new replies.