How to make WordPress Rest API parameters accessible without authentication?

How can I make certain parameters of the WordPress Rest API accessible to anyone without first being authenticated – for example, the page parameter doesn’t work (where blog is a custom post type) in this query:

mysite.com/wp-json/wp/v2/blog?page=2&per_page=20

I’ve seen that in the past it’s been possible to make these params available, for instance :

add_filter( 'json_query_vars', function( $valid_vars ) {

    $valid_vars[] = 'offset';

    return $valid_vars;
});

Is there any way to do something similar with today’s version of the API?

Read more here: How to make WordPress Rest API parameters accessible without authentication?

Leave a Reply

Your email address will not be published. Required fields are marked *