Allow duplicate taxonomy slugs? (4 posts)

  1. radgh
    Posted 3 years ago #

    I'm trying to set up a hierarchical taxonomy within my theme which also uses a hierarchical slug rewrite.

    This way I can have a category like "collections", with a subcategory like "earrings" which yet another subcategory like "hoops".

    One issue I've ran into is that there cannot be the same taxonomy slug stored, if a duplicate exists it appends the parent's slug to the end. Is there any way to allow duplicate entries?

    The problem I have is that there are multiple sub-categories of the same name which exist in different categories, but are totally independant.



    However, in creating these links, after defining the first series the second one became:


    I do not want this to occur, is there an alternative?

    EDIT: The code in use, although it's currently not "working" on the front end.

        'collections', // name/slug
        'collections', // object type (custom)
          'name' => 'Collections',
          'hierarchical' => true,
          'update_count_callback' => '_update_post_term_count',
          'labels' => $labels,
          'show_ui' => true,
          'query_var' => true,
          'rewrite' => array( 'hierarchical' => true ),

    And here is a screenshot of the taxonomy itself, notice simple-n-chic-earrings... that's the issue:


  2. degmsb
    Posted 2 years ago #

    Did you ever find a solution to this? I have the same issue and I am looking for a work around.

  3. radgh
    Posted 2 years ago #

    No I didn't. I ended up using my own system using custom URL structure and completely abandoned the slug field for the category. I used "sanitize_title" on the title of the category to get a slug-formatted title. It's all kind of hacky.

    If you want to set up a custom URL structure you can look up the filter "query_vars", the function "add_rewrite_rule" and finally you can access your wildcard using "get_query_var". Brian Fegter pointed me in the right direction for this on stackexchange: http://wordpress.stackexchange.com/questions/62846/using-custom-dynamic-slug-for-a-page

    Still, there may be a better way. Maybe one day when I have some more wordpress experience it will be worth making a plugin for this sort of category. But I don't know.

    Good luck.

  4. serpyre
    Posted 2 years ago #

    There is a plugin "Duplicate Category Paths" which does this for 3.x so you can have the same seo friendly url paths.

Topic Closed

This topic has been closed to new replies.

About this Topic