Add post meta in post (custom post type) endpoint with Rest API

Add post meta in post (custom post type) endpoint with Rest API.

Todo:

  • Change post-type with your post type slug.
  • Change prefix-meta-key with your post meta key which you want to include in Rest API Response.

Output:

Visit https://<mysite>/wp-json/wp/v2/<post-type>/ it show the stored data from meta key  prefix-meta-key in the Rest API response.

Code:

 

Advertisements