Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Latest commit

 

History

History
55 lines (42 loc) · 1.1 KB

link.md

File metadata and controls

55 lines (42 loc) · 1.1 KB

Link Field

Link fields are added to the WPGraphQL Schema as a field with the Type ACF_Link.

Link fields can be queried and a ACF_Link will be returned. The ACF Link is an object with fields that can be selected.

The available fields on the ACF_Link Type are:

  • target (String): The target of the link
  • title (String): The target of the link
  • url (String): The url of the link

Here, we have a Link field named link on the Post Edit screen within the "ACF Docs" Field Group.

Link field in the Edit Post screen

This field can be Queried in GraphQL like so:

{
  post(id: "acf-example-test", idType: URI) {
    acfDocs {
      link {
        target
        title
        url
      }
    }
  }
}

and the results of the query would be:

{
  "data": {
    "post": {
      "acfDocs": {
        "link": {
          "target": "",
          "title": "Hello world!",
          "url": "http://acf2.local/hello-world/"
        }
      }
    }
  }
}