Tag: custom fields

Filed under: Blog, Web Development, What I Learned

Getting Post Meta for the WP REST API

My friend and I are working on a little side project. It’s a job posting site for an industry we’re familiar with: ESL jobs around the world. While this project could be seen as “just another job board”, we’re hoping to add some features that will make it fun to use and valuable for schools and recruiters. I of course want to build it on WordPress, but to get a some of the functionality I want, I need to expose some post meta to the WP REST API.

In researching how to do this, I quickly found out that the WP REST API doesn’t naturally expose post or user meta. As with most things WP REST API, you don’t have to go too far down the rabbit hole before you find a practical article written by the Josh Pollock. While the register_api_field function isn’t in use anymore, the register_rest_field function is, so this article and that function were all I needed to get going.

Continue reading