I wanted to sanitize a WP_Query post object without using foreach.
I used this method:
$ args = array( // ... ) $ data = array(); $ the_query = new WP_Query($ args); $ data["post"] = $ the_query->posts; array_map("sanitize_post", $ data["post"]); return rest_ensure_response($ data);
output:
as you can see that filter is working and its turning to "Display" from "Raw".
But the problem is: <script>
tags still standing in post_title field.
Whats the problem?