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

Declare post collection params so they can be exposed - #1302

Closed
danielbachhuber wants to merge 5 commits into
developfrom
924-post-collection-query
Closed

danielbachhuber wants to merge 5 commits into
developfrom
924-post-collection-query

Conversation

@danielbachhuber

Copy link
Copy Markdown
Member

See #924, #555

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WP-API/amigos What should I do with legacy get_allowed_query_vars() ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API has always supported the public query_vars of WP_Query, included a few others, and provided a filter to add support for additional vars. There are some public query vars that are pretty pointless (example withcomments) but trying to normalize all these params sounds like a headache to me.

@danielbachhuber

Copy link
Copy Markdown
Member Author

@WP-API/amigos I'm not 100% sure what we decided to do with WP_Query-style arguments (e.g. also supporting posts_per_page in addition to page).

Given we don't support WP_User_Query-style arguments et al, and trying to magically support them would be a pretty massive hack, I think we should drop them for now.

@rachelbaker

Copy link
Copy Markdown
Member

I'm not 100% sure what we decided to do with WP_Query-style arguments

I don't know if we discussed this, but it sounds like we should.

@rachelbaker

Copy link
Copy Markdown
Member

Looks like this needs some more discussion. @rmccue @joehoyle thoughts?

@joehoyle

Copy link
Copy Markdown
Member

When we discussed this at LoopConf, I was under the impression we settled on the following:

  1. Create new query params, for example page, per_page, slug etc.
  2. Put all current WP_Query style WordPress query names under a filter or wp_query argument. So these would be equivalent:

GET /wp/v2/posts?per_page=10

GET /wp/v2/posts?wp_query[posts_per_page]=10

That way, we can support WordPress devs thinking the a WP_Query mindset, and give them the ability to construct more complex queries (though ofcourse of the public query vars that we currently use). Then have a clean top level args that will be consistent across all collections.

@danielbachhuber

Copy link
Copy Markdown
Member Author

GET /wp/v2/posts?wp_query[posts_per_page]=10

I dig this — seems like a reasonable compromise.

@rmccue

rmccue commented May 27, 2015

Copy link
Copy Markdown
Member

If we're going to do it, keep the filter name so it's consistent with v1. That way, v2 = v1 + additional better named querying, rather than completely different.

@danielbachhuber

Copy link
Copy Markdown
Member Author

I dig filter

@rmccue

rmccue commented Jun 17, 2015

Copy link
Copy Markdown
Member

Marking as Needs Refresh, since filter needs to be added in.

@danielbachhuber

Copy link
Copy Markdown
Member Author

Closing in favor of #1793

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants