I am using WP REST API. I want to get the posts from my blog and show them in my android app. So, everything is OK, but i need to ask a question to make sure about something: when i call posts in the content section; there is a lots of HTML tag, is there any way (another plugin or ... ) which return this part (or any part witch have HTML elements) as JSON or some how make it easier and separate the HTML tags? I am using HTML to java Parser but i just want to make sure about this.

1 Answer 1


You can (and you should) always filter the output of WP_REST_API.

add_filter('json_prepare_post', 'change_this_into_a_proper_function_name', 999);
function change_this_into_a_proper_function_name($post){
    // hack and slash into your $post here. This is a regular WP_Post
    // add custom fields and tax terms you might need, remove what
    // you don't want to expose to app or are never going to need...
    // This filtering step is actually a must imho, as it really influences
    // the speed at which your posts will load over poor connections.
    // Special care should be taken with attachments, I usually replace them
    // with versions of 800px width (or even 600) for both Android and IoS.
    return $post;

The only app where I didn't completely remove $post->content in favor of the excerpt was an app for a bookstore, where users were installing the app specifically to read book reviews. But even there, when pulling lists of reviews I was filtering the content out and only loaded it fully only on read more. It payed off. The app stayed agile even on poorly resourced devices.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.