1

I would like to create permalink to a search for a custom post type that has 2 taxonomies in it. Here are a few appropriate examples:

/root/%taxonomyA%/%taxonomyB%
/root/%taxonomyA%/taxonomyB/%taxonomyB%

Taxonomy B can be inside any number of Taxonomy As.

I already have something for this structure that works great:

/root/%taxonomyA%/%customPostType%

Is this possible? I prefer the 1st example, but I would be fine with the 2nd.

I did attempt to put this rewrite rule in, but I don't get the matches I expect in the rewrite inspector.

add_rewrite_rule(
    '^root/([^/]+)/taxonomyB/([^/]+)',
    'index.php?post_type=customPostType&taxonomyA=$matches[1]&taxonomyB=$matches[2]',
    'top'
);

When I put in root/A/taxonomyB/B the inspector, it comes up as attachment: B

0

I don't understand what you want to do. Every taxonomy is independent and the terms can't be shared between them. The only way I know to do a search with 2 parameters: taxonomy A term and taxonomy B term, and pass it to a WP Query along with the custom post type.

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.