Queries-BibliothekEinen alten Post-Slug durch einen neuen Slug in allen Posts ersetzen
Einen alten Post-Slug durch einen neuen Slug in allen Posts ersetzen
Nachdem du den Slug eines Posts geändert hast, führe diese query aus, um alle Inhalte so zu konvertieren, dass sie auf die neue URL verweisen.
Diese query erfordert, dass der Endpunkt Nested Mutations aktiviert hat.
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
}
}
}
}