Karlo Serrano
Karlo Serrano

Reputation: 71

Include postmeta in wordpress rest api

I am trying to include postmeta in json response. I already got the code here:

https://torquemag.io/2015/07/working-with-post-meta-data-using-the-wordpress-rest-api/

My problem is where do I add this code? My initial thoughts are to add them in functions.php within the theme. Or should I add it in functions.php inside wp-includes?

UPDATE: I added the code in plugin.php of rest-api and it worked. Is this the preferred approach? or is there a better way to do it?

Upvotes: 0

Views: 698

Answers (1)

Stephen
Stephen

Reputation: 8238

More or less the code above will work, but a much easier and elegant way to selectively expose your postmeta may be via this plugin.

Upvotes: 1

Related Questions