• Resolved Younes

    (@vanbom)


    I have a custom taxonomy product_category , and it accepts parent / child relationship.

    The url: /wp-json/wp/v2/product_category shows me everything, Parent and Child.

    is it possible to add parameters to get only the parents taxonomy?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    To get top level terms you can append ?parent=0. To get intermediate parents that are below top level you’d need to get them by their ID, which would be available in the child term’s “parent” field.

    There is a handy get_ancestors() function which returns all of a term’s ancestors up the line to the top level. You’d need to add a custom endpoint to access it though.

    Thread Starter Younes

    (@vanbom)

    Thank you @bcworkz
    It s woorks

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Get Custom taxonomy parent with wordpress REST API’ is closed to new replies.