Plugin-Daten abfragen
Plugin-Daten abfragenSlim SEO

Slim SEO

Beispiele für queries zur Interaktion mit Daten des Plugins Slim SEO.

SEO-Metadaten abrufen

Du kannst Meta-Felder verwenden, um SEO-Metadaten abzufragen:

query GetPost($postId: ID!) {
  post(by: { id: $postId }) {
    id
    title
 
    slimSeoMeta: metaValue(key: "slim_seo")
    metaTitle: _objectProperty(object: $__slimSeoMeta, by: { key: "title" }, failIfNonExistingKeyOrPath: false)
    metaDesc: _objectProperty(object: $__slimSeoMeta, by: { key: "description" }, failIfNonExistingKeyOrPath: false)
    fbImage: _objectProperty(object: $__slimSeoMeta, by: { key: "facebook_image" }, failIfNonExistingKeyOrPath: false)
    twitterImage: _objectProperty(object: $__slimSeoMeta, by: { key: "twitter_image" }, failIfNonExistingKeyOrPath: false)
    canonical: _objectProperty(object: $__slimSeoMeta, by: { key: "canonical" }, failIfNonExistingKeyOrPath: false)
  }
}

SEO-Metadaten aktualisieren

Du kannst Meta-Mutations verwenden, um SEO-Metadaten zu aktualisieren:

mutation UpdatePost($postId: ID!) {
  updateCustomPostMetas(inputs: [
    {
      id: $postId,
      key: "slim_seo",
      value: {
        title: "New title",
        description: "New description",
        facebook_image: "https://example.com/social-image.jpg",
        twitter_image: "https://example.com/social-image.jpg",
        canonical: "https://example.com/canonical-url"
      }
    }
  ]) {
    status
    errors {
      __typename
      ...on ErrorPayload {
        message
      }
    }
    customPost {
      __typename
      id
      slimSeoMeta: metaValue(key: "slim_seo")
      metaTitle: _objectProperty(object: $__slimSeoMeta, by: { key: "title" }, failIfNonExistingKeyOrPath: false)
      metaDesc: _objectProperty(object: $__slimSeoMeta, by: { key: "description" }, failIfNonExistingKeyOrPath: false)
      fbImage: _objectProperty(object: $__slimSeoMeta, by: { key: "facebook_image" }, failIfNonExistingKeyOrPath: false)
      twitterImage: _objectProperty(object: $__slimSeoMeta, by: { key: "twitter_image" }, failIfNonExistingKeyOrPath: false)
      canonical: _objectProperty(object: $__slimSeoMeta, by: { key: "canonical" }, failIfNonExistingKeyOrPath: false)
    }
  }
}