0

I have a 190 categories - 2 parents, 2 children each, each of those has 2 children, and each of those has between 10-20 bottom level categories.

The problem I've run into is that this is an apps portal - so all of the bottom level categories have the same names - "Apple/iOS--->Free---->fitness" where as the other is "Android - free - fitness" and so on.

This wasn't a problem using hiearchical menu systems…but I'm creating a custom search function and I want to display the top 14 categories - but their are duplicate names. I can't figure out how to do it like a menu (click on Apple, it drop down and only gives you Apple selections) so I'm using check boxes and it would be great if I didn't have two check boxes that said "free" or "paid" ;)

If I could create an alias for those categories so the checkboxes could be more explicit "Show Apple Free apps" - which wouldn't work in a menu. - that would be great.

Thanks! Rob ps…I know there may be tools out there to create a hiearchical search UI but I'm not running a standard config - I have an ElasticSearch Server setup and using the WP plugin ElasticPress.

4
  • 1
    This implies a problem with how you're categorising. If it were me, things like "Operating System", "Price" and "Fitness would be in different taxonomies, aka a "OS" taxonomy, a "Price" taxonomy, and a "App types" taxonomy. Luckily as your categories follow a set pattern, it should be trivial to create those taxonomies and reverse engineer which terms an app belongs to
    – Tom J Nowell
    Jun 12 '15 at 13:44
  • Hello Tom, thank you! Just got in from a long day and may not be thinking clearly but I'm not sure I follow you. The apps are in two groups "Fitness/Home Use" and "Healthcare/Medical". U Under each of those is "Apple/iOS" and "Android" and under each of those is "Free" and "Paid". Then for "healthcare/medical" I have Anesthesiology, Dermatology, etc…the same ones for both Apple and Android. Under health/fitness I have the same names for papps in both OS's.The top levels are what most would filter by so how could I create a taxonomy, put those top categories into them? I have 80,000+ apps/posts
    – Rob50
    Jun 13 '15 at 1:21
  • And yes, by the way, you're right - I should've have thought out the initial categorization naming schema. The problem now is, the apps have been categorized already - and it was a lot of work and I still had to cut some corners by creating a "Miscellaneous" category to dump stuff in, in the interim, until I could get to it (but I wanted it indexed). After I launch, take a breather, I may go back and do it all differently…but I really hope I can avoid that! LOL
    – Rob50
    Jun 13 '15 at 1:31
  • You create 3 taxonomies, Operating System ( e.g. Android, iOS), Price ( free, paid ), and a heirarchical category type taxonomy ( Health/Medical -> Anesthesiology ). Then your problem becomes significantly more manageable, and you don't all the problems that duplicating terms is giving you. All you then need is to list posts using the terms and taxonomies available ( e.g. the posts in the free price tag, and the iOS operating system tag, in the Health type )
    – Tom J Nowell
    Jun 13 '15 at 2:18
1

No, you cannot create an alias for term names.

But if you could, it would not be the optimal or easiest method.

Instead of having a single taxonomy were the top level is the OS, the children are the price, and the grandchildren are the app category, instead have 3 taxonomies:

  • Operating System ( iOS/Android/etc )
  • Pricing ( free/freemium/paid/etc )
  • App Type ( Health/Medical/etc )

Make App type a hierarchical taxonomy so that you can nest sub types category style.

This way you side step your problem entirely, and can list all free apps, or all Apple apps, or all medical apps. Your problem is now one of implementing taxonomy intersections, which is a solvable task, and one you don't even have to solve.

For example, lets say your post type is application, with an archive at example.com/apps and you have an operating_system and pricing taxonomies, you could go to this URL to view all free apps for iOS:

example.com/apps/?operating_system=ios&pricing=free

This should make implementing the search functionality you're building incredibly simple as you can make operating_system or pricing input fields in the search form and use the GET method

You could apply rewrite rules to create URLs such as:

example.com/apps/ios/free

But I won't cover rewrite rules as that's a separate topic you should ask about.

I would note that you can write code that makes use of wp_insert_term or wp_set_object_terms to assign and create terms in the 3 new taxonomies for each post, based on the existing taxonomy you're using.

In the end, your data structure is broken, and what you want cannot be done without restructuring ( which is not impossible )

3
  • Hello Tom, - Thank you again for your time! Just so I'm clear, your last line about restructuring - basically I can't do what I want without re-importing all my posts? And when you say "have 3 taxonomies" would you recommend a plugin or code it by hand? You probably guessed - I don't have any experience with anything other than categories and tags ;)
    – Rob50
    Jun 13 '15 at 14:40
  • I don't see why you would need to destroy your posts and recreate them, just loop over each post, grab the category, and use the result to set the terms in your new taxonomies. A WP CLI command would be ideal. ( categories and tags are taxonomies too, the only difference is they're bundled with WordPress )
    – Tom J Nowell
    Jun 13 '15 at 15:10
  • Hmmm…okay…I think I'm in over my head…I understand the words but totally clueless on how to accomplish what you're saying ;) I think it might be easier, for me at any rate, to just rename select categories for now so I can list them in my search in a way that makes sense. And I'll just remove the menu since I don't think many people will use the menu to "browse 200 categories & 80K posts". Then when I have the site in production I'll "loop" back to this and figure it out. Once again, I appreciate your time!
    – Rob50
    Jun 13 '15 at 16:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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