WordPress.org

Ready to get started?Download WordPress

Forums

Same slug on custom post type and hierarchical taxonomy (2 posts)

  1. nattila
    Member
    Posted 2 years ago #

    Hello,

    I have a Custom Post Type and a Hierarchical Taxonomy.

    [CSS moderated as per the Forum Rules. Please just post a link to your site.]

    With a post_type_link filter I can achieve the following URL structures:
    mysite.com/eskuvoi-ruhaszalon/category1/product-name1
    mysite.com/eskuvoi-ruhaszalon/category1/subcategory1/product-name1

    function filter_post_type_link($link, $post) {
        if ($post->post_type != 'wedding_salon') return $link;
        if ($cats = get_the_terms($post->ID, 'salon_location')) $link = str_replace('%salon_location%', array_pop($cats)->slug, $link);
        return $link;
    }
    add_filter('post_type_link', 'filter_post_type_link', 10, 2);

    But taxonomy subcategory pages return with 404 error. I can only access subcategories without hierarchical structure.

    mysite.com/eskuvoi-ruhaszalon/category1/subcategory1 - doesn't work 404
    mysite.com/eskuvoi-ruhaszalon/subcategory1 - it works

    Do you have any idea how can I fix hierarchical taxonomy URL structure in this case?

  2. nattila
    Member
    Posted 2 years ago #

    this is the part removed from previews post

    http://pastebin.com/FsqQD4DA

Topic Closed

This topic has been closed to new replies.

About this Topic