• Resolved andrejcremoznik

    (@andrejcremoznik)


    I have a custom post type (collections) with:
    'rewrite' => array('slug' => 'collections/%collection_cat%', 'with_front' => false, 'feeds' => false)

    and a custom taxonomy (collections_cat) with:
    'rewrite' => array('slug' => 'collections', 'with_front' => false, 'hierarchical' => true)

    I’m filtering the rewrite_rules_array with:

    $rules['collections/(.+)/?$']           = 'index.php?collection_cat=$matches[1]';
    $rules['collections/(.+)/(.+)/(.+)/?$'] = 'index.php?collections=$matches[3]';

    On front-end /collections/cat/ and /collections/cat/subcat/ work fine.

    /collections/cat/subcat/postname throws 404. Looking at $query, the postname isn’t recognized separately as the third match for the rewrite rule. So instead of ?collections=postname, ?collection_cat=cat/subcat/postname is queried.

    What is going on?

    I’ll appreciate any help I can get.

    Thanks

Viewing 1 replies (of 1 total)
  • Thread Starter andrejcremoznik

    (@andrejcremoznik)

    OK, so the custom rules should precede the wordpress ones. After prepending them to rewrite_rules_array everything works.

Viewing 1 replies (of 1 total)
  • The topic ‘Hierarchical taxonomy as custom post type path – URL rewrite issues’ is closed to new replies.