Wordpress将动态值添加到自定义分类网址中 [英] Wordpress prefix dynamic value to custom taxonomy url
问题描述
我有两个自定义分类法版本和功能
I have two custom taxonomies 'edition' and 'features'
我希望wordpress允许我为功能块添加版本中的值。
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/功能/访谈/
mysite.com/asia/features/interviews/
Wordpress会将网址转换为;
Wordpress would translate the url to;
mysite.com/index.php?features=interview&edition=asia
mysite.com/index.php?features=interview&edition=asia
然后加载功能分类模板,然后我可以获取版本 query_var 并相应地过滤模板。
and then loading the features taxonomy template where i can then grab the edition query_var and filter the templates accordingly.
我正在考虑使用 add_rewrite_rule
I'm thinking playing around with add_rewrite_rule would sort it am not sure.
任何帮助表示赞赏
欢呼
更新
好吧,我认为我是正确的,我写了一个重写规则;
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
哪个网址类似;
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.
有什么想法吗?
推荐答案
已解决,正确的规则是;
Solved, the correct rule was;
RewriteRule ^(media|asia|uk)/([^/]+/)*([^/]+)/? index.php?feature=$3&department=$1
这篇关于Wordpress将动态值添加到自定义分类网址中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!