Search post by post meta with rest api.

Use filter rest_{$this->post_type}_query to add the post meta support in WP Rest API.

Use below code snippet to add the post meta support for post type Post.

Syntax:

http://mysite.com/wp-json/wp/v2/post?meta_key=<meta-key>&meta_value=<meta-value&gt;

How to use?

E.g. Get posts which post meta already-visited value is true.

http://mysite.com/wp-json/wp/v2/post?meta_key=already-visited&meta_value=true

Code Snippet:

Advertisements