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

Author: Mahesh Waghmare

I'm a professional WordPress theme/plugin developer since 2012.

One thought on “Search post by post meta with rest api.”

  1. I blog frequently and I really thank you for your information. Thiis great article has truly peajed my interest.
    I’m going tto take a note of your blog annd keep checking for
    new information about once a week. I subscribed to your RSS
    feed as well.

    Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.