WordPress verilerini sorgula
WordPress verilerini sorgulaPost Etiketleri

Post Etiketleri

Bunlar, post etiket verilerini almak için queries örnekleridir.

Etiketleri alma

Post etiketlerinin listesi, ada göre sıralanmış ve post sayısı gösterilmiş:

query {
  postTags(
    sort: { order: ASC, by: NAME }
    pagination: { limit: 50 }
  ) {
    id
    name
    url
    postCount
  }
}

Bir posttaki tüm etiketler:

query {
  post(by: { id: 1 }) {
    tags {
      id
      name
      url
    }
  }
}

Postlardaki etiket adları:

query {
  posts {
    id
    title
    tagNames
  }
}

Önceden tanımlanmış etiketlerin listesi:

query {
  postTags(filter: { ids: [66, 70, 191] }) {
    id
    name
    url
  }
}

Etiketleri ada göre filtreleme:

query {
  postTags(filter: { search: "oo" }) {
    id
    name
    url
  }
}

Etiket sonuçlarını sayma:

query {
  postTagCount(filter: { search: "oo" })
}

Etiketleri sayfalama:

query {
  postTags(
    pagination: {
      limit: 5,
      offset: 5
    }
  ) {
    id
    name
    url
  }
}

Meta değerlerini alma:

query {
  postTags(
    pagination: { limit: 5 }
  ) {
    id
    name
    metaValue(
      key: "someKey"
    )
  }
}

Bir posta etiket atama

Mutation:

mutation {
  setTagsOnPost(
    input: {
      id: 1499, 
      tags: ["api", "development"]
    }
  ) {
    status
    errors {
      __typename
      ... on ErrorPayload {
        message
      }
    }
    postID
    post {
      tags {
        id
      }
      tagNames
    }
  }
}

İç içe mutation:

mutation {
  post(by: { id: 1499 }) {
    setTags(
      input: {
        tags: ["api", "development"]
      }
    ) {
      status
      errors {
        __typename
        ... on ErrorPayload {
          message
        }
      }
      postID
      post {
        tags {
          id
        }
        tagNames
      }
    }
  }
}

Post etiketi oluşturma, güncelleme ve silme

Bu query, post etiketi terimlerini oluşturur, günceller ve siler:

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
}