WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#38941 closed defect (bug) (wontfix)

REST API - filter syntax isn't available

Reported by: andfinally Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.7
Component: REST API Keywords:
Focuses: rest-api Cc:

Description

I'm on WordPress 4.7 beta 4, and I'm finding the filter syntax isn't working.

The filter argument is listed in the v2 docs http://v2.wp-api.org/reference/posts/. But when I do a GET request to /wp-json/ filter is not listed in the args for the /wp/v2/posts GET endpoint.

I have three posts in my local environment. When I do a GET request to /wp-json/wp/v2/posts/?categories=2 I get the one post that belongs to the category with the ID 2. This category has the name News and slug news.

When I do requests like
/wp-json/wp/v2/posts?filter[cat]=2
/wp-json/wp/v2/posts?filter[category_name]=News
/wp-json/wp/v2/posts?filter[posts_per_page]=1
I get all three of my posts. From what I read on StackOverflow, this suggests the API isn't recognising the filter.

Change History (3)

#1 @swissspidy
3 years ago

Hey there,

The filter param has been removed on purpose. See #38378 for more information. The docs haven't been updated yet.

#2 @andfinally
3 years ago

  • Resolution set to wontfix
  • Status changed from new to closed

I see! Thanks - good to know. I'll close this.

#3 @johnbillion
3 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.