These are examples of queries to fetch and modify post data.

Fetching posts permalink

A single post, with author and tags:

A list of 5 posts with their comments:

A list of predefined posts:

Filtering posts:

Counting post results:

Paginating posts:

Fetching meta values:

Fetching the logged-in user's posts permalink

Fields post, posts and postCount only retrieve posts with status "publish".

To fetch posts from the logged-in user, with any status ("publish", "pending", "draft" or "trash"), use these fields:

  • myPost
  • myPosts
  • myPostCount

Fetching "unrestricted" posts permalink

โš ๏ธ Note: These fields are available when module "Schema for the Admin" is enabled. Read more in guide Querying 'unrestricted' fields.

To fetch posts from any user, with any status ("publish", "pending", "draft" or "trash"), use these fields:

  • unrestrictedPost
  • unrestrictedPosts
  • unrestrictedPostCount

Creating posts permalink

Only logged-in users can create posts.

Updating posts permalink

Only users with the corresponding capabilities can edit posts.

This query uses nested mutations to update the post: