Struggling with content scraping and duplication with REST API? Here is the WordPress function code that can block the content rendering via RESET API.
function block_post_content_in_rest_api($response, $post, $request) {
if ($request->get_param('context') === 'view') {
// Replace the content data with an empty string
$response->data['content']['rendered'] = '';
}
return $response;
}
add_filter('rest_prepare_post', 'block_post_content_in_rest_api', 10, 3);
It will return the blank content when the RESET API requests the post content data.