These are examples of queries to fetch custom post data.
Fetch custom posts with CPTs "post"
and "page"
:
Fetch custom posts for a variety of CPTs (which must be enabled to be queryable via Settings):
Fetch custom posts filtering by category:
To create CPTs which do not require any additional fields over those from a Post
, you can use the createCustomPost
mutation.
This query creates an entry for the "my-portfolio"
CPT:
This query updates the title and content for the "my-portfolio"
CPT:
Or using nested mutations: