Saltar navegación

[Resuelto] Filter by taxonomy API REST

This support ticket is created hace 4 años. 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)

Etiquetado: 

Este tema contiene 1 respuesta, tiene 2 mensajes.

Última actualización por Luo Yang hace 4 años.

Asistido por: Luo Yang.

Autor
Mensajes
#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