Search code examples
jsonwordpresswordpress-rest-api

Remove "_links" or remove curly brackets from "curies" in Wordpress Rest API v2 output


I have tried to remove the "_links" object in the API Response with Unset and remove_links() functions but none of them seems to work, is there any other way to do it?

The "curies" part is making trouble because of the curly brackets on the URL {}, is there a way to hide this?

Thanks


Solution

  • Just use the _fields parameter to include only the fields you want.

    https://[your-host]/wp-json/wp/v2/posts?_fields=author,categories,comment_status,content,date,date_gmt,excerpt,featured_media,format,guid,id,link,meta,modified,modified_gmt,ping_status,slug,status,sticky,tags,template,title,type
    

    Source... https://developer.wordpress.org/rest-api/reference/posts/#schema