Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a custom taxonomy, which sets the with_front to false to try and get the URLs to look like /%type%/%brand%/%product%/, degrading as we go down. This however is driving me nuts. Everything in the code works, this works, but it causes every other page on the site to 404. I'd imagine the reason is something like with_front makes it think all requests are for elements of this taxonomy. But I can't work out how to fix it.

Just FYI, make labels is my lazy function that produces the labels we require for this.

register_taxonomy ('types','brands',
   array(
       'hierarchical' => false,
       'labels' => make_labels('Type'),
       'show_ui' => true,
       'query_var' => true,
       'rewrite' => array( 'with_front' => false, 'slug' => false)
   )
);

$types = get_terms('types');

foreach($types as $type) {
    add_rewrite_rule("^$type->slug/([^/]*)/([^/]*)/?","index.php?hd_types=$type->slug&brands=\$matches[1]&products=\$matches[2]",'bottom');
    add_rewrite_rule("^$type->slug/([^/]*)/?","index.php?brands=\$matches[1]&types=$type->slug",'bottom');
}

Then we create the custom post types brands and products.

Driving me nuts! Thanks in advance.

share|improve this question
add comment

1 Answer

The answer to the question is in the two following posts:

Permalinks in Custom Post types

Remove taxonomy slug from a custom hierarchical taxonomy permalink

You need to ignore the automated rewriting, as I have done, but you need to add $wp_rewrite->use_verbose_page_rules = true; to the mix, otherwise your pages will conflict with the rewrite rules you have established for your taxonomy.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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