Skip Navigation

[Resolved] Filter by taxonomy API REST

This support ticket is created 3 years, 8 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Luo Yang 3 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#1897279

I have a custom type and I want to be able to filter in the rest API only those that belong to a category.

How can I do it?

#1898239

Hello,

It needs custom codes. For example, you can follow WP document :
https://developer.wordpress.org/reference/hooks/rest_this-post_type_query/
Use filter hook rest_{$this->post_type}_query to trigger a PHP function, and add a custom endpoint, and filter the result by taxonomy, see similar thread here:
https://wordpress.stackexchange.com/questions/275543/custom-post-types-filtered-by-taxonomy-using-rest-api-v2

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.