Query Plugin Data
Query Plugin DataSEO Simple Pack

SEO Simple Pack

Examples of queries to interact with data from the SEO Simple Pack plugin.

Fetching SEO metadata

We can use meta fields to query SEO metadata:

query GetPost($postId: ID!) {
  post(by: { id: $postId }) {
    id
    title
 
    metaTitle: metaValue(key: "ssp_meta_title")
    metaDesc: metaValue(key: "ssp_meta_description")
    focusKeyword: metaValue(key: "ssp_meta_keyword")
    canonical: metaValue(key: "ssp_meta_canonical")
    socialImage: metaValue(key: "ssp_meta_image")
  }
}

Updating SEO metadata

We can use meta mutations to update SEO metadata:

mutation UpdatePost($postId: ID!) {
  updatePost(
    input: {
      id: $postId
      meta: {
        ssp_meta_title: ["New title"],
        ssp_meta_description: ["New description"],
        ssp_meta_keyword: ["New focus keyword"],
        ssp_meta_canonical: ["https://example.com/canonical-url"],
        ssp_meta_image: ["https://example.com/social-image.jpg"],
      }
    }
  ) {
    status
    errors {
      __typename
      ...on ErrorPayload {
        message
      }
    }
    post {
      id
      metaTitle: metaValue(key: "ssp_meta_title")
      metaDesc: metaValue(key: "ssp_meta_description")
      focusKeyword: metaValue(key: "ssp_meta_keyword")
      canonical: metaValue(key: "ssp_meta_canonical")
      socialImage: metaValue(key: "ssp_meta_image")
    }
  }
}