查询插件数据WP Meta SEO
WP Meta SEO
与 WP Meta SEO 插件数据交互的 Query 示例。
获取 SEO 元数据
我们可以使用元字段来查询 SEO 元数据:
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")
}
}更新 SEO 元数据
我们可以使用元变更来更新 SEO 元数据:
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