Wordpress prefix dynamic value to custom taxonomy

2019-09-18 19:59发布

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条回答
放荡不羁爱自由
2楼-- · 2019-09-18 20:20

Solved, the correct rule was;

RewriteRule ^(media|asia|uk)/([^/]+/)*([^/]+)/? index.php?feature=$3&department=$1
查看更多
登录 后发表回答