Skip to content

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

Description

@tristanisginger

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
);

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions