Skip to content

Is there a way to have response headers passed? #13

Description

@te-online

Thank you for this helpful library, the only one for accessing the WP REST API with PHP – as far as I can see!

Now, my goal is to load every available post from the REST API to display them in a frontend.

As of the current WordPress version, we can only get 100 posts per request from the API.

$client->posts()->get(
   null, 
   array(
      'per_page' => 100,
   )
);

Fortunately, there is a header X-WP-TotalPages, where I can see how many requests I would need to fire to get all available posts. (see https://wordpress.stackexchange.com/questions/217490/get-post-count-in-wp-rest-api-v2-and-get-all-categories/250589#250589).

However, I don't see a way to get this header from the $client instance. Is there a way that I don't see?

Right now I do requests, until there are no posts in the response anymore. This leads to one request that I could save.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions