WP GraphQL ToolkitDocs

Query templates

Start from proven query patterns.

Use these patterns as a starting point, then adapt fields and arguments to match the schema exposed by your WordPress site.

Content

Latest posts

Published posts with identifiers, slugs, excerpts, featured images, and pagination.

Routing

Page by URI

Resolve a WordPress page using its URI for dynamic frontend routes.

Navigation

Menu tree

Fetch menu items and parent relationships for frontend navigation.

Taxonomy

Posts by category

Filter content by category, tag, or a custom taxonomy term.

Search

Content search

Search exposed content types with pagination and result metadata.

Commerce

Product catalog

Query product listings, prices, images, and taxonomy data when WooGraphQL is active.

Page By URI

query PageByUri($uri: ID!) {
  nodeByUri(uri: $uri) {
    ... on Page {
      id
      title
      content
      slug
    }
  }
}

Paginated Posts

query Posts($after: String) {
  posts(first: 12, after: $after) {
    pageInfo { hasNextPage endCursor }
    nodes { id slug title excerpt }
  }
}

Template Safety

Templates are examples, not guaranteed drop-in operations. Validate every template against your endpoint because field names, nullability, permissions, and extension behavior vary between WordPress installations.