1

I try to figure out a rewrite problem, that is a somewhat over my head, so i ask here to find out what i can do.

I use this two solutions from Jeff 1 and Milo 2, to get a full-path url for my custom taxons and my cpt that i like to have for my Products.

Now, for the post's, all is working fine except that i like to build the same URLs on my taxonomy-{taxonomy}-{term}.php template, which hold a taxons-menu that will load only the child-terms.

this is the basic idea that i have build:

example: the product's is accessible under the url-path

example.com/basename/term/child-term/cpt-post.

this is nice and works even for deeper nested child-terms.

the problem is that on the taxonomy-{taxonomy}-{term}.php template (which hold's the child-terms menu) the URL is allways:

example.com/basename/term
example.com/basename/child-term
example.com/basename/grand-child-term/

but for a better logic it should be:

example.com/basename/term
example.com/basename/term/child-term
example.com/basename/term/child-term/grand-child-term/

like the endpoints from the cpt-post are.

my rewrite rules looks like this

add_filter('rewrite_rules_array', 'mmp_rewrite_rules');
function mmp_rewrite_rules($rules) {
$newRules  = array();
$newRules['mybase/(.+)/(.+)/?$'] = 'index.php?mybase=$matches[2]';
$newRules['mybase/(.+)/(.+)/(.+)/?$'] = 'index.php?mybase=$matches[3]';
$newRules['mybase/(.+)/(.+)/(.+)/(.+)/?$'] = 'index.php?mybase=$matches[4]';  
return array_merge($newRules, $rules);}  

i hope somebody have found a solution for this or can explain/help me with this how to exactly configure the 2 linked solutions. thanks a lot!!!

Your Answer

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

Browse other questions tagged or ask your own question.