Skip to content
This repository was archived by the owner on Sep 24, 2018. It is now read-only.
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

Description

@equatorapps

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.

Activity

  1. swissspidy commented on Nov 15, 2015

    @swissspidy

    According to the docs and the code parent=0 should work.

    Perhaps the 0 === $request['parent'] check fails because it's not an int, so that would be a bug.

  2. Toddses commented on Nov 16, 2015

    @Toddses
    Contributor

    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=0 endpoint should do the trick.

  3. equatorapps commented on Nov 16, 2015

    @equatorapps
    Author

    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.

  4. modified the milestones: 2.0 Beta 7, on Nov 16, 2015
  5. danielbachhuber commented on Nov 16, 2015

    @danielbachhuber
    Member

    Perhaps the 0 === $request['parent'] check fails because it's not an int, so that would be a bug.

    This is the problem. It was introduced in #1604. We'll fix this in 2.0 Beta 6.1

  6. added a commit that references this issue on Nov 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions