0

How does Wordpress fetches subcategories for a given category? I tried to figure it out from the code, but I have not succeeded.
My real question is: is it possible to make some recursive sql query that will select all the term descendants. Or the recursion must be on PHP level?

  • What are you trying to do that this solves? It's difficult to answer this appropriatley without the context. Are you trying to create a side menu for terms? – Tom J Nowell Sep 23 '19 at 21:07
  • @TomJNowell No, I rewrite a WP site to NodeJS and (at least at this step) I continue to use original Wordpress database. So I have write some replacements to Wordpress functions. For example, to get all post from certain category. – Shimon S Sep 24 '19 at 6:00
  • Now I see that WP fetches all category tree from DB and process it on PHP level. – Shimon S Sep 24 '19 at 14:34
  • That's a pretty massive piece of info you ommitted. Most people usually use Node for a frontend then make REST API calls to an existing WP interface, they don't interact with the WP database tables directly. Same goes for a lot of headless/decoupled frontends that talk to the REST API. It's a lot easier than re-implementing half of WP to get access to its data structures – Tom J Nowell Sep 24 '19 at 16:43

Your Answer

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

Browse other questions tagged or ask your own question.