Increase per_page limit in REST API

The collection params accessed via that filter appear to describe the available query params but are not actually used in the query. I think what you actually want is the rest_{$this->post_type}_query filter which allows you to modify the args before they are passed to WP_Query::query(). Also keep in mind that on the API request the … Read more

Filter posts by multiple custom taxonomy terms using AND operator in REST API v2 (WordPress)

I think I know the fix. I noticed that the plus sign (+) in the url arguments was automatically being stripped and converted into a space. My arg values ‘august+september’ were becoming ‘august september’ after decoding. I found out that ‘%2B’ is the code equivalent of the + symbol. So, instead of using: /wp-json/wp/v2/events?filter[event_categories]=august+september Use: … Read more

How to define a query parameter with REST API?

Yes, from the link you posted there are examples for both sanitising and validating the parameters. Validating does a check which can fail and block the API call from running; sanitising just does some operations to clean or interpret the parameter and does not stop the API call from running. An example of validation, taken … Read more

Are there server performance benefits to fetching only specific fields when querying the REST API?

I understand that having less data being downloaded improves the experience to the end user, but my question is related to the actual server performance, would the response be faster? Would adding _fields[]=id&_fields[]=title, etc… to the above url improve server performance? No it would not, and for several reasons. When you ask for a post … Read more

WordPress REST API validation

There is no such maxLength option in the WP REST API. You can pass a validate_callback though. Example: <?php add_action( ‘rest_api_init’, function () { register_rest_route( ‘myplugin/v1’, ‘/author/(?P<id>\d+)’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘my_awesome_func’, ‘args’ => array( ‘id’ => array( ‘validate_callback’ => function($param, $request, $key) { return is_numeric( $param ); } ), ), ) ); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)