在单个URL中组合多个自定义用户分类

San*_*ate 6 wordpress custom-taxonomy

我为用户创建了自定义用户分类法,并且它对单一分类法有效.

从Bellow参考指南我创建了自定义用户分类.

参考指南: - http://justintadlock.com/archives/2011/10/20/custom-user-taxonomies-in-wordpress

贝娄是分类学的结构

(registered taxonomy)  profession

                              Dietitian (under the profession )



(registered taxonomy) city
                         NewYork(under the city)
Run Code Online (Sandbox Code Playgroud)

我的slu name名称 expert

在这里,我想显示用户DietitianNewYorkcity中的过滤结果.因此,它将显示在配置文件中选择了上述选项的所有用户.

现在我想要www.test.com/expert/dietitian/newyork 用户在用户配置文件中选择了Dietitian,NewYork 的url .是否有任何解决方案可以结合使用Dietitian,NewYork

单个术语的网址如下: - www.test.com/expert/dietitian/

Dr.*_*ker 1

此重写规则应该有效(假设“专业”和“城市”是分类注册名称):

代码:

function custom_rewrite_rules() {
    add_rewrite_rule('^profession/(.*)/city/(.*)?', 'index.php?profession=$matches[1]&city=$matches[2]', 'top');
}
add_action('init', 'custom_rewrite_rules');
Run Code Online (Sandbox Code Playgroud)

将此代码保存到您的站点后,请记住刷新重写规则。

网址: http: //yourdomain.com/profession/dietitian/city/newyork/