0

I have created three taxonomies named “city”, “company” and “profession”. link structure of this taxonomy is as follows:

/city/london

/company/cocacola

/profession/sales

I want to use city taxonomy at the end of company and profession taxonomy. in that way i would like to filter companies and professions depending on cities. see as follows:

/company/cocacola/london

/profession/sales/london

It is possible to do it in that way? if so, how can i do it? any alternatives?

0

That's quite possible by changing add_permstruct or filtering rewrite_rules. But what is your strategy for generating links for city? How will implement second taxonomy?

I would go for implementing this as rewrite rule for something like

add_filter( 'rewrite_rules_array', function( $rules ) {
    global $wp_rewrite;

    $new_rules = array(
        '(company|profession)/([^/]+)/([^/]+)/?$' => 'index.php?$matches[1]=$matches[2]&city=$matches[3]'
    );

    $rules = array_merge($new_rules, $rules);
    return $rules;
});

However, this isn't optimal and you will need to generate the bunch of supported rules (paging feeds). But you still need to generate links for them and its up to you!

cheers.

  • Thank you @Butuzov . In fact, what I want to do is filtering out companies and professions by city. Do you have a better idea for that? – Ömer Faruk Apr 23 '18 at 7:24
  • Select post from city, then select companies, and professions assigned ot city. now you have filtered professions and companies. – Butuzov Apr 23 '18 at 7:47
  • But I need to show this in the link structure. That's my problem :) – Ömer Faruk Apr 23 '18 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.