Skip to content

Commit

Permalink
Support for WP Rest API paging (#1733)
Browse files Browse the repository at this point in the history
* Update README.md

Unecessary per_page mention in readme

* Simplify `httpExceptionHandler` with es6

* Add function that gets multiple WP pages

* Allow perPage to be configurable (with default of 10)

* Add auth to paginated requests

* Rename pagination function

* Fix exception handler

* Lint gatsby-node.js

* Add babel dependencies/config

* Don’t pass perPage parameter around

* Remove unused variable

* Code cleanup

* Default `per_page` to 100

* Use WP total pages header & code style and style format

* Revert "Add babel dependencies/config"

This reverts commit 973d85b.
  • Loading branch information
alexbassy authored and KyleAMathews committed Aug 10, 2017
1 parent f8956a6 commit f9b9f74
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 108 deletions.
17 changes: 0 additions & 17 deletions packages/gatsby-source-wordpress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,6 @@ The Authentication on Wordpress.com is not supported yet. This means that you wo
]
```


### How to raise the default and maximum number of posts to be returned in result set from REST API

To modify the `per_page` `default` and `maximum` arguments add the following to your functions.php

```php
add_filter( 'rest_endpoints', function( $endpoints ){
if ( ! isset( $endpoints['/wp/v2/posts'] ) ) {
return $endpoints;
}
$endpoints['/wp/v2/posts'][0]['args']['per_page']['default'] = 200; // defaults to 10
$endpoints['/wp/v2/posts'][0]['args']['per_page']['maximum'] = 200; // defaults to 100
return $endpoints;
});
```


## How to query : GraphQL

You can query nodes created from Wordpress using GraphQL like the following:
Expand Down
Loading

0 comments on commit f9b9f74

Please sign in to comment.