问题
I have two custom taxonomies 'edition' and 'features'
I'd like wordpress to allow me to prefix the slug of features with a value from editions.
For example if i go here;
mysite.com/asia/features/interviews/
Wordpress would translate the url to;
mysite.com/index.php?features=interview&edition=asia
and then loading the features taxonomy template where i can then grab the edition query_var and filter the templates accordingly.
I'm thinking playing around with add_rewrite_rule would sort it am not sure.
Any help appreciated
Cheers
UPDATE
Ok I think I'm semi on the right lines, I have a rewrite rule written;
RewriteRule ^(media|asia|uk)/([^/]+/)*(^/)? index.php?feature=$2&department=$1
Which takes a url like;
www.mysite.com/media/features/interviews/face-to-face/
but it converts it to;
index.php?feature=face-to-face/&department=asia
Some how I need to get rid of the last / but I'm not proficient enough in regular expressions to work it out.
any ideas?
回答1:
Solved, the correct rule was;
RewriteRule ^(media|asia|uk)/([^/]+/)*([^/]+)/? index.php?feature=$3&department=$1
来源:https://stackoverflow.com/questions/16251287/wordpress-prefix-dynamic-value-to-custom-taxonomy-url