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

How do I filter by a property in an ACF group? #9

Open
tristanisginger opened this issue Feb 16, 2021 · 0 comments
Open

How do I filter by a property in an ACF group? #9

tristanisginger opened this issue Feb 16, 2021 · 0 comments

Comments

@tristanisginger
Copy link

Hi

This plugin seems very neat but i'm having trouble find examples of what I want to achieve. Please can you point me in the right direction.

I'd like to filter all packages with a max price http://localhost/wp-json/acf/v3/packages?max_price=1001

The json is as follows

[{
      "id": 1,
      "acf": {
        "packages": {
          "title": "I am a doge",
          "price": "1000",
        }
      }
    }]

And my the code

add_filter( 'rest_query_vars', function ( $valid_vars ) {
    return array_merge( $valid_vars, array( 'max_price', 'meta_query' ) );
} );

add_filter( 'rest_packages_query', function( $args, $request ) {
// missing code
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant