쿼리 라이브러리모든 게시물에서 이전 게시물 슬러그를 새 게시물 슬러그로 교체하기
모든 게시물에서 이전 게시물 슬러그를 새 게시물 슬러그로 교체하기
게시물의 슬러그를 변경한 후, 이 쿼리를 실행하여 모든 콘텐츠가 새 URL을 가리키도록 변환하세요.
이 쿼리를 실행하려면 엔드포인트에서 중첩 Mutation이 활성화되어 있어야 합니다.
query ExportData(
$oldPostSlug: String!
$newPostSlug: String!
) {
siteURL: optionValue(name: "siteurl")
oldPostURL: _strAppend(
after: $__siteURL,
append: $oldPostSlug
) @export(as: "oldPostURL")
newPostURL: _strAppend(
after: $__siteURL,
append: $newPostSlug
) @export(as: "newPostURL")
}
mutation ReplaceOldWithNewSlugInPosts
@depends(on: "ExportData")
{
posts(
filter: {
search: $oldPostURL
},
pagination: {
limit: -1
}
) {
id
rawContent
adaptedRawContent: _strReplace(
search: $oldPostURL
replaceWith: $newPostURL
in: $__rawContent
)
update(input: {
contentAs: { html: $__adaptedRawContent }
}) {
status
errors {
__typename
...on ErrorPayload {
message
}
}
post {
id
rawContent
}
}
}
}