• Hi

    I’m trying to create categories for my tech website I’m currently setting up and I’ve come across a slight problem with clashing child category names. Now I understand that parent categories can’t share similar names because every slug needs to be unique. However, in theory, child categories with the same name and should still work so long as the parent category is different as this makes up the other half of the URL/slug.

    Moreover, the problem I’m facing is that when using categories/taxonomies to filter posts and pages on a widget or plugin such as a post grid I’m using, they never display the categories correctly. I was thinking the categories would be displayed in some form of a hierarchy order with the indentation showing the differentiation between the parent and child categories. Even at a minimum, I was hoping the order of categories listed on the categories organising page would mirror in the widget/plugin.

    Here’s an example of the categories that are set in the categories page.

    Car
    Mercedes Benz
    Suzuki
    BMW
    Renault
    Triumph
    Ford

    Van
    Mercedes Benz
    Renault
    Ford

    Bike
    Suzuki
    BMW
    Triumph

    As you can see there are child categories that are shared under multiple parent categories. Luckily that doesn’t pose a problem as the slug will contain the parent category e.g.

    https://domain.com/car/mercedes-benz

    It’s using a widget/plugin when it becomes an annoyance because the order jumbles up so I may get two child categories listed on top of one another e.g.

    Ford
    Ford

    Some would say I should try not to use matching child categories, but unfortunately, I can’t get away from this

    Is there a way around this please?

    Many thanks

    Will

    • This topic was modified 6 years, 1 month ago by willowen100.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Category names are unique, and that doesn’t matter where they are placed in parent/child locations. It’s not grat, but to have the searching be correct, that’s how it’s done.

    What you’d be better off doing is trying to find a plugin or something that can do a many-to-many relationship between terms. I haven’t seen it before, but i haven’t tried it before either.

    Thread Starter willowen100

    (@willowen100)

    My website is currently using the Elementor page builder and I’m trying to use some filters to filter out certain posts/pages on a post grid for example. Unfortunately this is impossible due to the list being all over the place in a random order. We have many parent categories which obviously are all unique but we also have many child categories with the same name. This shouldn’t be a concern for WordPress to handle as the parent category’s URL/slug is used as a prefix for any of the child categories.

    For example I have a parent category called ‘Food’ and child category under this called ‘Chocolate’. Now if I create a second parent category called ‘Sweets’ and put ‘Chocolate’ under this we nos have two separate chocolate child categories BUT with different parents. This creates the following URL/slug’s:-

    domain.com/category/food/chocolate
    domain.com/category/sweets/chocolate

    Even though the child categories are absolutely identical, they are completely oblivious to one another. I just don’t understand why Elementor has problems displaying this in the page builder.

    Is there not a function I can place in the ‘functions.php’ file that displays the parent and child categories in an alphabetical order and indent each time hierarchy level drops?

    Many thanks

    Will

    catacaustic

    (@catacaustic)

    For questions with Elementor, you’ll need to ask them for assistance. Commercial products aren’t supported in these forums, so the best place to get supprot is the vendors for those products.

    Thread Starter willowen100

    (@willowen100)

    Putting Elementor aside. I have discovered a slight problem. I thought WordPress could have matching child slugs but after recently adding some more child categories I received a message saying it couldn’t be done. As you can see in the example below the hierarchy of categories can become quite complex. Is there a setting I can make so that I can set slugs of the same name for categories and tags, but with different parents? If I renamed a slug for

    Men
        Tops
            Polo shirt

    to comply with each slug being a unique name I would have stupidly long as:-
    https://www.domain.com/category/men/men-tops/men-tops-polo-shirt

    A more ideal slug would be:-
    https://www.domain.com/category/men/tops/polo-shirt

    Men
        Tops
            Dress shirt
            Polo shirt
            T-shirt
        Trousers
            Overalls
            Cargo
            Denim
        Shoes
            Trainers
            Sandals
            Smart shoes
            Boots
    Women
        Tops
            Dress shirt
            Polo shirt
            T-shirt
        Trousers
            Overalls
            Cargo
            Denim
        Shoes
            Trainers
            Sandals
            Smart shoes
            Boots
    
    Children
        Tops
            Dress shirt
            Polo shirt
            T-shirt
        Trousers
            Overalls
            Cargo
            Denim
        Shoes
            Trainers
            Sandals
            Smart shoes
            Boots

    Can someone clarify on this please?

    Many thanks

    Will

    catacaustic

    (@catacaustic)

    I already clarified that at the start. ??

    Category names are unique, and that doesn’t matter where they are placed in parent/child locations. It’s not great, but to have the searching be correct, that’s how it’s done.

    Thread Starter willowen100

    (@willowen100)

    There is a way to do it with the ‘functions.php’ file.

    How to include parent terms in hierarchical taxonomy URLs?
    Is there a way to create duplicated subcategory slugs on WordPress?

    However, I’m not sure how I set this to all categories.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Child Categories With Same Name Different Parent’ is closed to new replies.