Filter output of posts (Rest API)

Question

I have some custom post types. I use register_post_meta to register meta fields – with show_in_rest so the data can be accessed via the Rest API. I use prepare_callback to run a custom function to clean up the output – e.g to remove tags.

I want to do the same for the post content – specifically the title. But I can’t find an equivalent place to attach a callback.

I prefer to do the XSS filtering on the output rather than the input. At any event I can’t use DISALLOW_UNFILTERED_HTML because in places I want to save html tags.

How can I run a callback on the output via the Rest API of post and custom post data (not the meta data) so I can modify what is returned?

Thank you.

0
Kropotkin 2 months 2023-01-26T13:47:19-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse