Problem:
The user would like to exclude some fields from REST API calls
Solution:
This will need custom code, check this example:
// This is to enable the filtering at all.
add_filter( 'toolset_rest_run_exposure_filters', '__return_true' );
// exclude "book-additional-notes" custom field from "book" custom post type.
add_filter( 'toolset_rest_expose_field', function(
$expose_field, $domain, $group_slug, $field_slug, $element_type, $element_id
) {
if( 'posts' === $domain && 'book' == $element_type && 'book-additional-notes' == $field_slug ) {
return false;
}
// Different case - do not alter the result.
return $expose_field;
}, 10, 6 );
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/types-api-filters/#toolset_rest_expose_field
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 |
Zona horaria del colaborador: Africa/Casablanca (GMT+01:00)
Este tema contiene 5 respuestas, tiene 2 mensajes.
Última actualización por 4 years, 11 months ago.
Asistido por: Jamal.