I am working on a plugin where I have to create taxonomy.

But due to my requirement with little bit complexity, I have to create taxonomy without register_taxonomy().

Can somebody give me hints regarding this?

  • 2
    Can you explain more about why you can't use register_taxonomy? You can use variables in that call so it's hard to imagine a use case where you wouldn't have access to that function.
    – WebElaine
    May 23 '17 at 13:21

Well, I don't know whats your situation, but I would suggest you to use register_taxonomy() function to create a taxonomy for your posts or other custom post type. But if you don't wanna use this default system then there are some other ways to do that also.

Before going to the procedures we must know what actually taxonomies do. They just group some elements or thing together. So if we can group some element together without using register_taxonomy() function then it can be used as a taxonomy for this elements. So now the question is how can we group the elements ? Here comes the procedures part. Sure there are plenty of them, but this time I can suggest you the below ways-

  1. Use Post Meta: You can use post meta to contain a token which will represent a certain group. The you can query based on that token and this way you can classify the posts per group. In short this post meta will work as a taxonomy.
  2. Custom Database Tables: You can use two custom database tables to store the terms and the term-object relation. For each term in the terms table a value would be inserted. And in another table the relation between terms and elements or object will be saved. This way you can also have the taxonomy functionality without calling register_taxonomy().

But remember, usually creating taxonomy functionality using register_taxonomy() is the best practice and the taxonomies should be created this way.

Hope the above answer help you.

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.