You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 24, 2018. It is now read-only.
Repository navigation
This repository was archived by the owner on Sep 24, 2018. It is now read-only.
How to GET only top level terms (without parent) #1735
We are using WP-API v2 beta-5 and the following path: wp-json/wp/v2/terms/product_cat/ to get the woo commerce categories we have entered, and there are many. I have tried to use parent=0, but that does nothing. parent=xxx only seems to work for whole numbers. Is there another parameter or path to get just terms without a parent? Thanks.
Thanks guys! I have updated to beta6, but my results are the same as before. parent=0 returns all terms. parent=234 returns only terms with that parent id.
Activity
swissspidy commentedon Nov 15, 2015
According to the docs and the code
parent=0should work.Perhaps the
0 === $request['parent']check fails because it's not an int, so that would be a bug.Toddses commentedon Nov 16, 2015
There's a bug in the terms controller beta-5 which prevents you from making a request for only top-level terms (ie. terms with parent 0).
A fix landed in beta-6. So if you update, the
wp-json/wp/v2/terms/product_cat?parent=0endpoint should do the trick.equatorapps commentedon Nov 16, 2015
Thanks guys! I have updated to beta6, but my results are the same as before. parent=0 returns all terms. parent=234 returns only terms with that parent id.
danielbachhuber commentedon Nov 16, 2015
This is the problem. It was introduced in #1604. We'll fix this in 2.0 Beta 6.1
Failng test case for #1735