การ Query ข้อมูลปลั๊กอิน
การ Query ข้อมูลปลั๊กอินElementor

Elementor

อ่านเพิ่มเติมในคู่มือ Working with Elementor

ตัวอย่าง queries สำหรับโต้ตอบกับข้อมูลจากปลั๊กอิน Elementor

การดึงข้อมูล Elementor

query นี้ดึงข้อมูล Elementor จากโพสต์ (เก็บไว้เป็น meta ภายใต้รายการ _elementor_data) โดยคงโครงสร้างข้อมูลตามที่จัดเก็บใน DB:

{
  post(by: { id: 1 }) {
    elementorData
  }
}

query นี้ดึงข้อมูล Elementor จากโพสต์ โดยแปลงให้เป็นระดับเดียว:

{
  post(by: { id: 1 }) {
    elementorFlattenedDataItems
  }
}

การอัปเดตข้อมูล Elementor

mutation นี้ผสานองค์ประกอบเฉพาะในข้อมูล Elementor:

mutation {
  elementorMergeCustomPostElementDataItem(input: {
    customPostID: 1
    elements: [
      {
        id: "164e55c4",
        settings: {
          title: "Updated title"
        }
      }
    ]
  }) {
    status
    errors {
      __typename
      ...on ErrorPayload {
        message
      }
    }
    customPost {
      __typename
      ...on CustomPost {
        id
        elementorData
      }
    }
  }
}