Plugin-Daten abfragen
Plugin-Daten abfragenRank Math

Rank Math

Beispiele für queries zur Interaktion mit Daten des Rank Math Plugins.

SEO-Metadaten abrufen

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

query GetPost($postId: ID!) {
  post(by: { id: $postId }) {
    id
    title
 
    metaDesc: metaValue(key: "rank_math_description")
    focusKeyword: metaValue(key: "rank_math_focus_keyword")
    canonical: metaValue(key: "rank_math_canonical_url")
    socialTitle: metaValue(key: "rank_math_facebook_title")
    socialDesc: metaValue(key: "rank_math_facebook_description")
    socialImage: metaValue(key: "rank_math_facebook_image")
    twitterTitle: metaValue(key: "rank_math_twitter_title")
    twitterDesc: metaValue(key: "rank_math_twitter_description")
    twitterImage: metaValue(key: "rank_math_twitter_image")
  }
}

SEO-Metadaten aktualisieren

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

mutation UpdatePost($postId: ID!) {
  updatePost(
    input: {
      id: $postId
      meta: {
        rank_math_description: ["New description"],
        rank_math_focus_keyword: ["New focus keyword"],
        rank_math_canonical_url: ["https://example.com/canonical-url"],
        rank_math_facebook_title: ["Social title"],
        rank_math_facebook_description: ["Social description"],
        rank_math_facebook_image: ["https://example.com/social-image.jpg"],
        rank_math_twitter_title: ["Twitter title"],
        rank_math_twitter_description: ["Twitter description"],
        rank_math_twitter_image: ["https://example.com/twitter-image.jpg"],
      }
    }
  ) {
    status
    errors {
      __typename
      ...on ErrorPayload {
        message
      }
    }
    post {
      id
      metaDesc: metaValue(key: "rank_math_description")
      focusKeyword: metaValue(key: "rank_math_focus_keyword")
      canonical: metaValue(key: "rank_math_canonical_url")
      socialTitle: metaValue(key: "rank_math_facebook_title")
      socialDesc: metaValue(key: "rank_math_facebook_description")
      socialImage: metaValue(key: "rank_math_facebook_image")
      twitterTitle: metaValue(key: "rank_math_twitter_title")
      twitterDesc: metaValue(key: "rank_math_twitter_description")
      twitterImage: metaValue(key: "rank_math_twitter_image")
    }
  }
}