Query Plugin DataWP Meta SEO
WP Meta SEO
Examples of queries to interact with data from the WP Meta SEO 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: "_metaseo_metatitle")
    metaDesc: metaValue(key: "_metaseo_metadesc")
    focusKeyword: metaValue(key: "_metaseo_metaspecific_keywords")
    socialFBTitle: metaValue(key: "_metaseo_metaopengraph-title")
    socialFBDesc: metaValue(key: "_metaseo_metaopengraph-desc")
    socialFBImage: metaValue(key: "_metaseo_metaopengraph-image")
    socialTwitterTitle: metaValue(key: "_metaseo_metatwitter-title")
    socialTwitterDesc: metaValue(key: "_metaseo_metatwitter-desc")
    socialTwitterImage: metaValue(key: "_metaseo_metatwitter-image")
  }
}Updating SEO metadata
We can use meta mutations to update SEO metadata:
mutation UpdatePost($postId: ID!) {
  updateCustomPostMetas(inputs: [
    { id: $postId, key: "_metaseo_metatitle", value: "New title" },
    { id: $postId, key: "_metaseo_metadesc", value: "New description" },
    { id: $postId, key: "_metaseo_metaspecific_keywords", value: "New focus keyword" },
    { id: $postId, key: "_metaseo_metaopengraph-title", value: "Social title" },
    { id: $postId, key: "_metaseo_metaopengraph-desc", value: "Social description" },
    { id: $postId, key: "_metaseo_metaopengraph-image", value: "https://example.com/social-image.jpg" },
    { id: $postId, key: "_metaseo_metatwitter-title", value: "Social title" },
    { id: $postId, key: "_metaseo_metatwitter-desc", value: "Social description" },
    { id: $postId, key: "_metaseo_metatwitter-image", value: "https://example.com/social-image.jpg" },
  ]) {
    status
    errors {
      __typename
      ...on ErrorPayload {
        message
      }
    }
    customPost {
      __typename
      id
      metaTitle: metaValue(key: "_metaseo_metatitle")
      metaDesc: metaValue(key: "_metaseo_metadesc")
      focusKeyword: metaValue(key: "_metaseo_metaspecific_keywords")
      socialFBTitle: metaValue(key: "_metaseo_metaopengraph-title")
      socialFBDesc: metaValue(key: "_metaseo_metaopengraph-desc")
      socialFBImage: metaValue(key: "_metaseo_metaopengraph-image")
      socialTwitterTitle: metaValue(key: "_metaseo_metatwitter-title")
      socialTwitterDesc: metaValue(key: "_metaseo_metatwitter-desc")
      socialTwitterImage: metaValue(key: "_metaseo_metatwitter-image")
    }
  }
}Next
