Skip to content

Commit

Permalink
Docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbillion committed Aug 20, 2024
1 parent 20713d4 commit 11b753b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
12 changes: 9 additions & 3 deletions packages/wp-types/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,22 +245,28 @@ Usage with entity records:

```ts
import type {
WP_REST_API_Category,
WP_REST_API_Posts,
WP_REST_API_Term,
} from 'wp-types';

const category = getEntityRecord<WP_REST_API_Term>(
const category = getEntityRecord<WP_REST_API_Category>(
'taxonomy',
'category',
id,
);

const term = getEntityRecord<WP_REST_API_Term>(
'taxonomy',
taxonomy,
id,
);

const posts = getEntityRecords<WP_REST_API_Posts>(
'postType',
'post',
query
query,
);
const taxonomy = getEntityRecord('taxonomy', taxonomy, term);
```

## FAQs
Expand Down
5 changes: 3 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,18 +218,19 @@ printf(
The REST API object schemas apply to the response to a REST API request or `getEntityRecord()` call. Examples:

```js
// WP_REST_API_Categories
const api = wp.apiFetch( {
path: '/wp/v2/categories/'
} );
```

```js
// WP_REST_API_Category
const category = getEntityRecord(
'taxonomy',
'category',
id,
);

// WP_REST_API_Posts
const posts = getEntityRecords(
'postType',
'post',
Expand Down

0 comments on commit 11b753b

Please sign in to comment.