Skip to content
This repository has been archived by the owner on Sep 24, 2018. It is now read-only.

Query params for collections #924

Closed
danielbachhuber opened this issue Feb 25, 2015 · 14 comments
Closed

Query params for collections #924

danielbachhuber opened this issue Feb 25, 2015 · 14 comments

Comments

@danielbachhuber
Copy link
Member

If you have a bug to report relating to querying for posts, terms, users, comments, etc., please open a new issue — this issue is intended to be a master reference.

This issue is a master issue representing work on query parameters in collections. Here's a table of the currently supported parameters:

+----------------+-------+-------+-------+----------+------------+-------+-------+
| param          | posts | pages | media | comments | categories | tags  | users |
+----------------+-------+-------+-------+----------+------------+-------+-------+
| after          |   x   |   x   |   x   |   x      |            |       |       |
| author         |   x   |   x   |   x   |   x      |            |       |       |
| author_email   |       |       |       |   x      |            |       |       |
| author_exclude |   x   |   x   |   x   |   x      |            |       |       |
| before         |   x   |   x   |   x   |   x      |            |       |       |
| context        |   x   |   x   |   x   |   x      |   x        |   x   |   x   |
| exclude        |   x   |   x   |   x   |   x      |   x        |   x   |   x   |
| filter         |   x   |   x   |   x   |          |            |       |       |
| hide_empty     |       |       |       |          |   x        |   x   |       |
| include        |   x   |   x   |   x   |   x      |   x        |   x   |   x   |
| karma          |       |       |       |   x      |            |       |       |
| media_type     |       |       |   x   |          |            |       |       |
| menu_order     |       |   x   |       |          |            |       |       |
| mime_type      |       |       |   x   |          |            |       |       |
| offset         |   x   |   x   |   x   |   x      |            |   x   |   x   |
| order          |   x   |   x   |   x   |   x      |   x        |   x   |   x   |
| orderby        |   x   |   x   |   x   |   x      |   x        |   x   |   x   |
| page           |   x   |   x   |   x   |   x      |   x        |   x   |   x   |
| parent         |       |   x   |   x   |   x      |   x        |       |       |
| parent_exclude |       |   x   |   x   |   x      |            |       |       |
| per_page       |   x   |   x   |   x   |   x      |   x        |   x   |   x   |
| post           |       |       |       |   x      |   x        |   x   |       |
| search         |   x   |   x   |   x   |   x      |   x        |   x   |   x   |
| slug           |   x   |   x   |   x   |          |   x        |   x   |   x   |
| status         |   x   |   x   |   x   |   x      |            |       |       |
| type           |       |       |       |   x      |            |       |       |
+----------------+-------+-------+-------+----------+------------+-------+-------+

Related #605

@danielbachhuber danielbachhuber added this to the 2.0 milestone Feb 25, 2015
@danielbachhuber danielbachhuber self-assigned this Feb 28, 2015
@danielbachhuber danielbachhuber modified the milestones: 2.0 Beta 1, 2.0 Mar 30, 2015
@rachelbaker
Copy link
Member

Punting to Beta 2.

kadamwhite added a commit to WP-API/node-wpapi that referenced this issue Jan 21, 2016
Slug searches are cumbersome; filtering was originally added in
WP-API/WP-API#924 but has been removed again in the v2 betas
(see WP-API/WP-API#924 for latest status)

Integration tests demonstrate the best option we currently have,
which is to search for the term then iterate through the responses
from that search until you find a match.
@danielbachhuber danielbachhuber removed their assignment Feb 5, 2016
@davidsteinberger
Copy link

What was the specific reason to remove menu_order from the posts-endpoint?

@danielbachhuber
Copy link
Member Author

What was the specific reason to remove menu_order from the posts-endpoint?

Posts don't support menu_order, Pages do.

@davidsteinberger
Copy link

Well yes, but there are tons of plugins that do provide a menu_order. In the previous beta menu_order was still allowed, but now it's blocked. Do you know what's the proper way for me to re-enable that again (just for myself)?

@joneslloyd
Copy link

Hey - just asking to confirm:

Right now will filtering a CPT to those with a specific parent ID not work?

For example: http://example.com/wp-json/wp/v2/my-cpts?filter[parent]=304 ?

If not, do you know if this is something in progress? I can help achieve this if you need an extra hand

@danielbachhuber
Copy link
Member Author

Do you know what's the proper way for me to re-enable that again (just for myself)?

You should be able to use /wp/v2/posts?filter[menu_order]

Right now will filtering a CPT to those with a specific parent ID not work?

It should work — the filter key is post_parent though: /wp/v2/my-cpts?filter[post_parent]=304

@joneslloyd
Copy link

@danielbachhuber Thanks fore getting back to me!

Unfortunately that doesn't seem to be working for CPTs. I've not modified the returned data (etc.) which is weird.

When I try what you've written, I just get [] returned

@joneslloyd
Copy link

Just to let you know, this is definitely an issue.

When trying to filter by ID (/wp/v2/my-cpts?filter[id]=333) it returns the full set (all posts of the CPT, unfiltered).

When trying to filter by post parent (as above in previous reply) it returns a blank array.

@BE-Webdesign
Copy link
Member

@joneslloyd id isn't a WP_Query param nor do I believe there is an id param being added to filter as a mask for the WP_Query params. So I am pretty sure filter[id] doesn't work causing everything to be returned. To do what you are trying to do I highly recommend this. /wp/v2/my-cpts/333 or if you want filter it could be /wp/v2/my-cpts?filter[p]=333.

When trying to filter by post parent (as above in previous reply) it returns a blank array.

I can check about the use of post_parent and see if I can duplicate an empty result set. @joneslloyd please open this in a separate issue if you want it addressed though this is a master reference and not intended for these kind of discussions.

@rmccue
Copy link
Member

rmccue commented Sep 22, 2016

We're closing this ticket out in favour of more concrete tickets instead. If you have anything you need with params, please file a new issue.

@rmccue rmccue closed this as completed Sep 22, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants