Interrogare i dati dei plugin
Interrogare i dati dei pluginSEO Simple Pack

SEO Simple Pack

Esempi di queries per interagire con i dati del plugin SEO Simple Pack.

Recuperare i metadati SEO

Possiamo usare i campi meta per interrogare i metadati SEO:

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")
  }
}

Aggiornare i metadati SEO

Possiamo usare le mutazioni meta per aggiornare i metadati SEO:

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")
    }
  }
}