WordPress 데이터 쿼리포스트 태그
포스트 태그
다음은 포스트 태그 데이터를 가져오는 쿼리 예시입니다.
태그 가져오기
포스트 태그 목록을 이름순으로 정렬하고 포스트 수와 함께 표시합니다:
query {
postTags(
sort: { order: ASC, by: NAME }
pagination: { limit: 50 }
) {
id
name
url
postCount
}
}포스트 내 모든 태그:
query {
post(by: { id: 1 }) {
tags {
id
name
url
}
}
}포스트 내 태그 이름:
query {
posts {
id
title
tagNames
}
}미리 정의된 태그 목록:
query {
postTags(filter: { ids: [66, 70, 191] }) {
id
name
url
}
}이름으로 태그 필터링:
query {
postTags(filter: { search: "oo" }) {
id
name
url
}
}태그 결과 수 계산:
query {
postTagCount(filter: { search: "oo" })
}태그 페이지네이션:
query {
postTags(
pagination: {
limit: 5,
offset: 5
}
) {
id
name
url
}
}메타 값 가져오기:
query {
postTags(
pagination: { limit: 5 }
) {
id
name
metaValue(
key: "someKey"
)
}
}포스트에 태그 설정하기
뮤테이션:
mutation {
setTagsOnPost(
input: {
id: 1499,
tags: ["api", "development"]
}
) {
status
errors {
__typename
... on ErrorPayload {
message
}
}
postID
post {
tags {
id
}
tagNames
}
}
}중첩 뮤테이션:
mutation {
post(by: { id: 1499 }) {
setTags(
input: {
tags: ["api", "development"]
}
) {
status
errors {
__typename
... on ErrorPayload {
message
}
}
postID
post {
tags {
id
}
tagNames
}
}
}
}포스트 태그 생성, 수정 및 삭제
이 쿼리는 포스트 태그 텀을 생성, 수정 및 삭제합니다:
mutation CreateUpdateDeletePostTags {
createPostTag(input: {
name: "Some name"
slug: "Some slug"
description: "Some description"
}) {
status
errors {
__typename
...on ErrorPayload {
message
}
}
category {
...PostTagData
}
}
updatePostTag(input: {
id: 1
name: "Some updated name"
slug: "Some updated slug"
description: "Some updated description"
}) {
status
errors {
__typename
...on ErrorPayload {
message
}
}
category {
...PostTagData
}
}
deletePostTag(input: {
id: 1
}) {
status
errors {
__typename
...on ErrorPayload {
message
}
}
}
}
fragment PostTagData on PostTag {
id
name
slug
description
}