Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using meta_key and meta_value custom field arguments #91

Open
emilesilvis opened this issue Mar 20, 2014 · 3 comments
Open

Using meta_key and meta_value custom field arguments #91

emilesilvis opened this issue Mar 20, 2014 · 3 comments

Comments

@emilesilvis
Copy link

http://foo.co.za/wp_api/v1/posts?post_type=foo works, but I'm struggling to get http://foo.co.za/wp_api/v1/posts?post_type=foo&meta_key=bar&meta_value=baz to work.

Any ideas?

PS. Awesome plugin!

@shshaw
Copy link

shshaw commented Apr 16, 2014

Looking through the documentation and the code, it doesn't appear that meta_key and meta_value are accepted as parameters. Not sure there's a reason why, but it may just not be implemented yet.

@shshaw
Copy link

shshaw commented Apr 16, 2014

It looks like by adding

            'meta_key' => array( ),
            'meta_value' => array( ),

after line #107 of api/v1/controllers/Posts.php allows using those url parameters with no further tweaking necessary. Your example query of /wp_api/v1/posts?post_type=foo&meta_key=bar&meta_value=baz should work without a hitch.

Combined with @fardog's gist (or my small fork to fix a warning) and you have fantastic custom field support in Thermal API.

To the devs: Is there a reason these fields weren't included in the API? Security concerns or other issues? Any plans to implement better custom field support into the core?

@prettyboymp
Copy link
Collaborator

Meta was left out due to security concerns. We wanted to avoid making anything publicly queryable that wsan't normally public in WordPress. The convert_request() method in the posts controller does need to be reworked some to allow new request args to added to the query.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants