• Resolved netizenconsultant

    (@netizenconsultant)


    Hi,

    I am using WP Rest API V2 to get my WP post and display in my mobile apps. When I get the wp post, I got response like this :

    <p><span style=\"font-size: 14pt;\"><strong><em>Amerika Serikat menaikkan kelas Indonesia dari negara berkembang jadi negara maju. Namun ternyata ada risikonya lho. Apa saja?</em></strong></span></p>\n<p><span style=\"font-size: 14pt;\"><em>Yuk</em> simak informasi selengkapnya dalam artikel di bawah ini!</span></p>\n<p>&nbsp;</p>\n<p><span style=\"font-size: 14pt;\">Rubrik </span></p>\n<p><img class=\"aligncenter wp-image-7096 size-full\" title=\"Rubrik and News\" src=\"link\" alt=\"Rubrik and News\" width=\"482\" height=\"128\" srcset=\"link 200w, link 300w, link 400w, link 482w\" sizes=\"(max-width: 482px) 100vw, 482px\" /></p>\n<p>&nbsp;</p>\n<h2><span style=\"font-size: 18pt;\">AS Cabut Indonesia dari Daftar Negara Berkembang!</span></h2>\n<p><span style=\"font-size: 14pt;\"><a title=\"China\" href=\"link/tag/china/
    

    The tag is unreadable in my native apps. How can I modify the WP Rest API so I only got text only from the API?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • The post content is HTML, so that is what you get.
    If you write a filter for it that would be triggered by the REST API, would you want all accesses of it to be changed? The editor uses the REST API also, you know.
    Most likely, you should strip the HTML in your app.

    Thread Starter netizenconsultant

    (@netizenconsultant)

    Hi @joyously
    I do not want to change all of the WP API. Maybe only added some code in function.php to remove all of the content beside text. Any suggestion?

    Thanks

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Post contents do contain HTML. They’re not just text. If you want to remove the HTML tags, then you should do it in post-processing on whatever you have displaying the content, and not on the WordPress side of things.

    You can’t remove it from the REST API because then you would not be able to edit it properly in the WordPress editor.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Modify WP Rest API V2 responses’ is closed to new replies.