Nav Menu Item Fields
How to get values from Nav Menu Item ACF custom fields
On this page will be shown examples how to get values of ACF custom fields related to Nav Menu Items.
We have to use acf_value
field of GraphQL NavMenuItem type to get value of any ACF field type.
This field takes one argument that is the name of the field.
Some ACF field types(Post Object, Relationship, Taxonomy, User, Group, Repeater) have their own specific GraphQL fields to get values in advanced way.
Example for Text field:
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items{
custom_text: acf_value(name: "custom_text")
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_text": "My Important Custom Text1"
},
1: {
"custom_text": "My Important Custom Text2"
}
]
}
}
Example for Text Area field:
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_text_area: acf_value(name: "custom_text_area")
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_text_area": "My Important Custom Text1"
},
1: {
"custom_text_area": "My Important Custom Text2"
}
]
}
}
Example for Number field:
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_number: acf_value(name: "custom_number")
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_number": 12345
},
1: {
"custom_number": 67891
}
]
}
}
Example for Range field:
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_range: acf_value(name: "custom_range")
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_range": 123
},
1: {
"custom_range": 345
}
]
}
}
Example for Email field:
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
email: acf_value(name: "custom_email")
}
}
}
{
"nav_menu": {
"items": [
0: {
"email": "[email protected]"
},
1: {
"email": "[email protected]"
}
]
}
}
Example for URL field:
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_url: acf_value(name: "custom_url")
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_url": "https://builderius.io/"
},
1: {
"custom_url": "https://demo.builderius.io/"
}
]
}
}
Example for Password field:
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
some_api_key: acf_value(name: "some_api_key")
}
}
}
{
"nav_menu": {
"items": [
0: {
"some_api_key": "<your secret key1 to some api>"
},
1: {
"some_api_key": "<your secret key2 to some api>"
}
]
}
}
Example for Image field:
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_image: acf_value(name: "custom_image")
}
}
}
- Image Array
- Image URL
- Image ID
{
"nav_menu": {
"items": [
0: {
"custom_image": {
"ID":54,
"id":54,
"title":"1aedbdaf-02d6-3eca-8cfe-e60ff037185b",
"filename":"1aedbdaf-02d6-3eca-8cfe-e60ff037185b.jpg",
"filesize":82299,
"url":"https://builderius.test/wp-content/uploads/2021/08/1aedbdaf-02d6-3eca-8cfe-e60ff037185b.jpg",
"link":"https://builderius.test/?attachment_id=54",
"alt":"",
"author":"1",
"description":"",
"caption":"",
"name":"1aedbdaf-02d6-3eca-8cfe-e60ff037185b",
"status":"inherit",
"uploaded_to":0,
"date":"2021-08-17 09:39:09",
"modified":"2021-08-17 09:39:09",
"menu_order":0,
"mime_type":"image/jpeg",
"type":"image",
"subtype":"jpeg",
"icon":"https://builderius.test/wp-includes/images/media/default.png",
"width":1419,
"height":946,
"sizes": {
"thumbnail":"https://builderius.test/wp-content/uploads/2021/08/1aedbdaf-02d6-3eca-8cfe-e60ff037185b-150x150.jpg",
"thumbnail-width":150,
"thumbnail-height":150,
"medium":"https://builderius.test/wp-content/uploads/2021/08/1aedbdaf-02d6-3eca-8cfe-e60ff037185b-300x200.jpg",
"medium-width":300,
"medium-height":200,
}
}
}
]
}
}
{
"nav_menu": {
"items": [
0: {
"custom_image": "https://builderius.test/wp-content/uploads/2021/08/1aedbdaf-02d6-3eca-8cfe-e60ff037185b.jpg"
}
]
}
}
{
"nav_menu": {
"items": [
0: {
"custom_image": 54
}
]
}
}
Example for File field:
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_file: acf_value(name: "custom_file")
}
}
}
- File Array
- File URL
- File ID
{
"nav_menu": {
"items": [
0: {
"custom_file": {
"mime_type": "application/rtf",
"caption": "",
"filename": "custom-text-file.rtf",
"alt": "",
"modified": "2021-08-21 14:28:14",
"author": "1",
"name": "custom-text-file",
"menu_order": 0,
"date": "2021-08-21 14:17:19",
"url": "https://builderius.test/wp-content/uploads/2021/08/custom-text-file.rtf",
"status": "inherit",
"title": "custom-text-file",
"icon": "https://builderius.test/wp-includes/images/media/document.png",
"uploaded_to": 55,
"subtype": "rtf",
"type": "application",
"link": "https://builderius.test/?attachment_id=107",
"ID": 107,
"id": 107,
"description": "",
"filesize": 379
}
}
]
}
}
{
"nav_menu": {
"items": [
0: {
"custom_file":"https://builderius.test/wp-content/uploads/2021/08/custom-text-file.rtf"
}
]
}
}
{
"nav_menu": {
"items": [
0: {
"custom_file": 107
}
]
}
}
Example for Wysiwyg Editor field:
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_wysiwyg_editor_text: acf_value(name: "custom_wysiwyg_editor_text")
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_wysiwyg_editor_text": "<p><img loading=\"lazy\" class=\"alignnone size-medium wp-image-48\" src=\"https://builderius.test/wp-content/uploads/2021/08/f0b76547-3355-3565-a625-3a6302a447ca-300x200.jpg\" alt=\"\" width=\"300\" height=\"200\" srcset=\"https://builderius.test/wp-content/uploads/2021/08/f0b76547-3355-3565-a625-3a6302a447ca-300x200.jpg 300w, https://builderius.test/wp-content/uploads/2021/08/f0b76547-3355-3565-a625-3a6302a447ca-1024x683.jpg 1024w, https://builderius.test/wp-content/uploads/2021/08/f0b76547-3355-3565-a625-3a6302a447ca-768x512.jpg 768w, https://builderius.test/wp-content/uploads/2021/08/f0b76547-3355-3565-a625-3a6302a447ca.jpg 1326w\" sizes=\"(max-width: 300px) 100vw, 300px\" />This <strong>is </strong><em>my </em>custom <em><strong>text</strong></em></p>"
}
]
}
}
Example for oEmbed field:
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_oembed: acf_value(name: "custom_oembed")
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_oembed": "<iframe title=\"Working in the panel\" width=\"640\" height=\"360\" src=\"https://www.wetube.com/embed/FpvcAhQFljs?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>"
}
]
}
}
Example for Gallery field:
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_gallery: acf_value(name: "custom_gallery")
}
}
}
- Image Array
- Image URL
- Image ID
{
"nav_menu": {
"items": [
0: {
"custom_gallery":[
{
"ID":54,
"id":54,
"title":"1aedbdaf-02d6-3eca-8cfe-e60ff037185b",
"filename":"1aedbdaf-02d6-3eca-8cfe-e60ff037185b.jpg",
"filesize":82299,
"url":"https://builderius.test/wp-content/uploads/2021/08/1aedbdaf-02d6-3eca-8cfe-e60ff037185b.jpg",
"link":"https://builderius.test/?attachment_id=54",
"alt":"",
"author":"1",
"description":"",
"caption":"",
"name":"1aedbdaf-02d6-3eca-8cfe-e60ff037185b",
"status":"inherit",
"uploaded_to":0,
"date":"2021-08-17 09:39:09",
"modified":"2021-08-17 09:39:09",
"menu_order":0,
"mime_type":"image/jpeg",
"type":"image",
"subtype":"jpeg",
"icon":"https://builderius.test/wp-includes/images/media/default.png",
"width":1419,
"height":946,
"sizes":{
"thumbnail":"https://builderius.test/wp-content/uploads/2021/08/1aedbdaf-02d6-3eca-8cfe-e60ff037185b-150x150.jpg",
"thumbnail-width":150,
"thumbnail-height":150,
"medium":"https://builderius.test/wp-content/uploads/2021/08/1aedbdaf-02d6-3eca-8cfe-e60ff037185b-300x200.jpg",
"medium-width":300,
"medium-height":200
}
},
{
"ID":56,
"id":56,
"title":"74863257-ddad-35f4-867b-b1cbf5cd52e1",
"filename":"74863257-ddad-35f4-867b-b1cbf5cd52e1.jpg",
"filesize":93643,
"url":"https://builderius.test/wp-content/uploads/2021/08/74863257-ddad-35f4-867b-b1cbf5cd52e1.jpg",
"link":"https://builderius.test/?attachment_id=56",
"alt":"",
"author":"1",
"description":"",
"caption":"",
"name":"74863257-ddad-35f4-867b-b1cbf5cd52e1",
"status":"inherit",
"uploaded_to":0,
"date":"2021-08-17 09:39:10",
"modified":"2021-08-20 21:53:34",
"menu_order":0,
"mime_type":"image/jpeg",
"type":"image",
"subtype":"jpeg",
"icon":"https://builderius.test/wp-includes/images/media/default.png",
"width":1028,
"height":685,
"sizes":{
"thumbnail":"https://builderius.test/wp-content/uploads/2021/08/74863257-ddad-35f4-867b-b1cbf5cd52e1-150x150.jpg",
"thumbnail-width":150,
"thumbnail-height":150,
"medium":"https://builderius.test/wp-content/uploads/2021/08/74863257-ddad-35f4-867b-b1cbf5cd52e1-300x200.jpg",
"medium-width":300,
"medium-height":200
}
}
]
}
]
}
}
{
"nav_menu": {
"items": [
0: {
"custom_gallery":[
0: "https://builderius.test/wp-content/uploads/2021/08/1aedbdaf-02d6-3eca-8cfe-e60ff037185b.jpg",
1: "https://builderius.test/wp-content/uploads/2021/08/74863257-ddad-35f4-867b-b1cbf5cd52e1.jpg"
]
}
]
}
}
{
"nav_menu": {
"items": [
0: {
"custom_gallery":[
0: 54,
1: 56
]
}
]
}
}
Example for Select field:
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_select: acf_value(name: "custom_select")
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_select": "red"
}
]
}
}
Example for Checkbox field:
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_checkbox: acf_value(name: "custom_checkbox")
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_checkbox": [
0: "red",
1: "green"
]
}
]
}
}
Example for Radio Button field:
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
"items": [
0: {
custom_radio_button: acf_value(name: "custom_radio_button")
}
]
}
}
{
"nav_menu": {
"items": [
0: {
"custom_radio_button": "red"
}
]
}
}
Example for Button Group field:
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_button_group: acf_value(name: "custom_button_group")
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_button_group": "red"
}
]
}
}
Example for True / False field:
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_bool: acf_value(name: "custom_bool")
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_bool": false
}
]
}
}
Example for Link field:
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_link: acf_value(name: "custom_link")
}
}
}
- Link Array
- Link URL
{
"nav_menu": {
"items": [
0: {
"custom_link": {
"title":"Sample Page",
"url":"https://builderius.test/?page_id=2",
"target":"_blank"
}
}
]
}
}
{
"nav_menu": {
"items": [
0: {
"custom_link": "https://builderius.test/?page_id=2"
}
]
}
}
Example for Post Object field (basic method):
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_post_object: acf_value(name: "custom_post_object")
}
}
}
- Post Object
- Post ID
- No
- Yes
{
"nav_menu": {
"items": [
0: {
"custom_post_object": {
"post_excerpt":"",
"post_mime_type":"",
"post_modified":"2021-08-17 09:43:55",
"post_parent":0,
"guid":"https://builderius.test/?p=53",
"post_author":"1",
"post_name":"sequi-qui-blanditiis-provident",
"post_date":"2021-08-16 18:03:45",
"menu_order":0,
"comment_count":"0",
"post_status":"publish",
"pinged":"",
"comment_status":"open",
"to_ping":"",
"post_modified_gmt":"2021-08-17 09:43:55",
"filter":"raw",
"post_title":"Sequi qui blanditiis provident",
"post_type":"post",
"post_password":"",
"post_content":"<here will be post_content as it saved in DB, so all Gutenberg blocks will be like html comments>",
"ID":53,
"post_content_filtered":"",
"post_date_gmt":"2021-08-16 18:03:45",
"ping_status":"open",
}
}
]
}
}
{
"nav_menu": {
"items": [
0: {
"custom_post_object": [
0: {
"post_excerpt":"",
"post_mime_type":"",
"post_modified":"2021-08-17 09:43:55",
"post_parent":0,
"guid":"https://builderius.test/?p=53",
"post_author":"1",
"post_name":"sequi-qui-blanditiis-provident",
"post_date":"2021-08-16 18:03:45",
"menu_order":0,
"comment_count":"0",
"post_status":"publish",
"pinged":"",
"comment_status":"open",
"to_ping":"",
"post_modified_gmt":"2021-08-17 09:43:55",
"filter":"raw",
"post_title":"Sequi qui blanditiis provident",
"post_type":"post",
"post_password":"",
"post_content":"<here will be post_content as it saved in DB, so all Gutenberg blocks will be like html comments>",
"ID":53,
"post_content_filtered":"",
"post_date_gmt":"2021-08-16 18:03:45",
"ping_status":"open",
}
]
}
]
}
}
- No
- Yes
{
"nav_menu": {
"items": [
0: {
"custom_post_object": 53
}
]
}
}
{
"nav_menu": {
"items": [
0: {
"custom_post_object": [53, 54]
}
]
}
}
Example for Post Object field with single value (advanced method):
GraphQL NavMenuItem type has field "acf_post_object_value" which purpose is to get value of ACF Post Object field with "Select multiple values?" setting selected as "No".
But comparing to "acf_value" - "acf_post_object_value" always returns Post GraphQL type(no matter which return format was selected for ACF Post Object field).
This method gives us more power and flexibility:
- we can get just necessary fields of Post
- we can get meta values of this Post
- we can get FeaturedImage of this Post
- we can get own ACF fields of this Post
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_post_object: acf_post_object_value(name: "custom_post_object") {
ID
post_title
post_content
some_meta_key: meta_value(key: "some_meta_key")
custom_acf_value: acf_value(name: "custom_acf_field_name")
}
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_post_object": {
"ID": 53,
"post_title": "Sequi qui blanditiis provident",
"post_content": " <here will be rendered post content, Gutenberg blocks will be rendered>",
"some_meta_key": "<here will be meta value>",
"custom_acf_value": "<here will be value of ACF field>"
}
}
]
}
}
Example for Post Object field with multiple values (advanced method):
GraphQL NavMenuItem type has field "acf_multiple_post_object_value" which purpose is to get value of ACF Post Object field with "Select multiple values?" setting selected as "Yes".
"acf_multiple_post_object_value" always returns array of Post GraphQL types(of course if "Select multiple values?" setting was selected as "Yes").
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_multiple_post_object: acf_multiple_post_object_value(name: "custom_multiple_post_object") {
ID
post_title
post_content
some_meta_key: meta_value(key: "some_meta_key")
custom_acf_value: acf_value(name: "custom_acf_field_name")
}
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_multiple_post_object": [
0: {
"ID": 53,
"post_title": "Sequi qui blanditiis provident",
"post_content": " <here will be rendered post content, Gutenberg blocks will be rendered>",
"some_meta_key": "<here will be meta value>",
"custom_acf_value": "<here will be value of ACF field>"
},
1: {
"ID": 54,
"post_title": "Sequi qui blanditiis",
"post_content": " <here will be rendered post content, Gutenberg blocks will be rendered>",
"some_meta_key": "<here will be meta value>",
"custom_acf_value": "<here will be value of ACF field>"
}
]
}
]
}
}
Example for Page Link field:
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_page_link: acf_value(name: "custom_page_link")
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_page_link": "https://builderius.test/?p=55"
}
]
}
}
Example for Relationship field (basic method):
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_relationship: acf_value(name: "custom_relationship")
}
}
}
- Post Object
- Post ID
{
"nav_menu": {
"items": [
0: {
"custom_relationship": [
0: {
"post_excerpt": "",
"post_mime_type": "",
"post_modified": "2021-08-17 09:45:03",
"post_parent": 0,
"guid": "https://builderius.test/?p=47",
"post_author": "1",
"post_name": "omnis-nesciunt-quasi-amet-officiis",
"post_date": "2021-08-16 01:57:54",
"menu_order": 0,
"comment_count": "0",
"post_status": "publish",
"pinged": "",
"comment_status": "open",
"to_ping": "",
"post_modified_gmt": "2021-08-17 09:45:03",
"filter": "raw",
"post_title": "Omnis nesciunt quasi amet officiis",
"post_type": "post",
"post_password": "",
"post_content": "<here will be post_content as it saved in DB, so all Gutenberg blocks will be like html comments>",
"ID": 47,
"post_content_filtered": "",
"post_date_gmt": "2021-08-16 01:57:54",
"ping_status": "closed"
},
1: {
"post_excerpt": "",
"post_mime_type": "",
"post_modified": "2021-08-17 09:43:55",
"post_parent": 0,
"guid": "https://builderius.test/?p=53",
"post_author": "1",
"post_name": "sequi-qui-blanditiis-provident",
"post_date": "2021-08-16 18:03:45",
"menu_order": 0,
"comment_count": "0",
"post_status": "publish",
"pinged": "",
"comment_status": "open",
"to_ping": "",
"post_modified_gmt": "2021-08-17 09:43:55",
"filter": "raw",
"post_title": "Sequi qui blanditiis provident",
"post_type": "post",
"post_password": "",
"post_content": "<here will be post_content as it saved in DB, so all Gutenberg blocks will be like html comments>",
"ID": 53,
"post_content_filtered": "",
"post_date_gmt": "2021-08-16 18:03:45",
"ping_status": "open"
}
]
}
]
}
}
{
"nav_menu": {
"items": [
0: {
"custom_relationship": [
0: 47,
1: 53
]
}
]
}
}
Example for Relationship field (advanced method):
GraphQL NavMenuItem type has field "acf_relationship_value" which purpose is to get ACF Relationship field value.
But comparing to "acf_value" - "acf_relationship_value" always returns Array of GraphQL Post types(no matter which return format was selected for ACF Relationship field).
This method gives us more power and flexibility:
- we can get just necessary fields of each Post
- we can get meta values of each Post
- we can get FeaturedImage of each Post
- we can get own ACF fields of each Post
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_relationship: acf_relationship_value(name: "custom_relationship") {
ID
post_title
post_content
some_meta_key: meta_value(key: "some_meta_key")
custom_acf_value: acf_value(name: "custom_acf_field_name")
}
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_relationship": [
0: {
"ID": 47,
"post_title": "Omnis nesciunt quasi amet officiis",
"post_content": "<here will be rendered post content, Gutenberg blocks will be rendered>",
"some_meta_key": "<here will be meta value>",
"custom_acf_value": "<here will be value of ACF field>"
},
1: {
"ID": 53,
"post_title": "Sequi qui blanditiis provident",
"post_content": "<here will be rendered post content, Gutenberg blocks will be rendered>",
"some_meta_key": "<here will be meta value>",
"custom_acf_value": "<here will be value of ACF field>"
}
]
}
]
}
}
Example for Taxonomy field (basic method):
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_taxonomy: acf_value(name: "custom_taxonomy")
}
}
}
- Term Object
- Term ID
- Checkbox or Multi Select
- Radio Buttons or Select
{
"nav_menu": {
"items": [
0: {
"custom_taxonomy": [
0: {
"parent":0
"name":"Uncategorized"
"slug":"uncategorized"
"term_group":0
"term_id":1
"count":5
"taxonomy":"category"
"term_taxonomy_id":1
"filter":"raw"
"description":""
}
]
}
]
}
}
{
"nav_menu": {
"items": [
0: {
"custom_taxonomy": {
"parent":0
"name":"Uncategorized"
"slug":"uncategorized"
"term_group":0
"term_id":1
"count":5
"taxonomy":"category"
"term_taxonomy_id":1
"filter":"raw"
"description":""
}
}
]
}
}
- Checkbox or Multi Select
- Radio Buttons or Select
{
"nav_menu": {
"items": [
0: {
"custom_taxonomy": [
0: 1
]
}
]
}
}
{
"nav_menu": {
"items": [
0: {
"custom_taxonomy": 1
}
]
}
}
Example for Taxonomy field with single value (advanced method):
GraphQL NavMenuItem type has field "acf_taxonomy_value" which purpose is to get value of ACF Taxonomy field with "Appearance" setting selected as "Radio Buttons" or "Select".
But comparing to "acf_value" - "acf_taxonomy_value" always returns Term GraphQL type(no matter which return format was selected for ACF Taxonomy field).
This method gives us more power and flexibility:
- we can get just necessary fields of Term
- we can get meta values of this Term
- we can get own ACF fields of this Term
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_term: acf_taxonomy_value(name: "custom_taxonomy") {
term_id
slug
description
some_meta_key: meta_value(key: "some_meta_key")
custom_acf_value: acf_value(name: "custom_acf_field_name")
}
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_term": {
"term_id": 1,
"slug": "uncategorized",
"description": "Uncategorized",
"some_meta_key": "<here will be meta value>",
"custom_acf_value": "<here will be value of ACF field>"
}
}
]
}
}
Example for Taxonomy field with multiple values (advanced method):
GraphQL NavMenuItem type has field "acf_multiple_taxonomy_value" which purpose is to get value of ACF Taxonomy field with "Appearance" setting selected as "Checkbox" or "Multi Select".
"acf_multiple_taxonomy_value" always returns array of GraphQL Term types(of course if "Appearance" setting was selected as "Checkbox" or "Multi Select").
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_term: acf_multiple_taxonomy_value(name: "custom_taxonomy") {
term_id
slug
description
some_meta_key: meta_value(key: "some_meta_key")
custom_acf_value: acf_value(name: "custom_acf_field_name")
}
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_term": [
0: {
"term_id": 1,
"slug": "uncategorized",
"description": "Uncategorized",
"some_meta_key": "<here will be meta value>",
"custom_acf_value": "<here will be value of ACF field>"
},
1: {
"term_id": 2,
"slug": "categorized",
"description": "Categorized",
"some_meta_key": "<here will be meta value>",
"custom_acf_value": "<here will be value of ACF field>"
}
]
}
]
}
}
Example for User field (basic method):
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_user: acf_value(name: "custom_user")
}
}
}
- User Array
- User Object
- User ID
- No
- Yes
{
"nav_menu": {
"items": [
0: {
"custom_user": {
"user_firstname":"admin",
"user_description":"super admin",
"user_email":"[email protected]",
"display_name":"admin",
"user_avatar":"<img alt='' src='https://secure.gravatar.com/' srcset='https://secure.gravatar.com/' class='avatar photo' height='96' width='96' loading='lazy'/>",
"nickname":"admin",
"user_lastname":"admin",
"user_registered":"2021-08-17 09:28:57",
"ID":1,
"user_url":"https://builderius.test",
"user_nicename":"admin",
}
}
]
}
}
{
"nav_menu": {
"items": [
0: {
"custom_user": [
0: {
"user_firstname":"admin",
"user_description":"super admin",
"user_email":"[email protected]",
"display_name":"admin",
"user_avatar":"<img alt='' src='https://secure.gravatar.com/' srcset='https://secure.gravatar.com/' class='avatar photo' height='96' width='96' loading='lazy'/>",
"nickname":"admin",
"user_lastname":"admin",
"user_registered":"2021-08-17 09:28:57",
"ID":1,
"user_url":"https://builderius.test",
"user_nicename":"admin",
}
]
}
]
}
}
- No
- Yes
{
"nav_menu": {
"items": [
0: {
"custom_user": {
"data":{
"user_pass":"<encrypted password>",
"user_status":"0",
"user_email":"[email protected]",
"display_name":"admin",
"user_activation_key":"",
"user_login":"admin",
"user_registered":"2021-08-17 09:28:57",
"ID":"1",
"user_url":"https://builderius.test",
"user_nicename":"admin",
}
"ID":1,
"caps":{
"administrator":true
},
"cap_key":"wp_capabilities",
"roles":[
0:"administrator"
],
"allcaps":{
"update_themes":true,
"edit_files":true,
"edit_private_posts":true,
"publish_posts":true,
"delete_private_posts":true,
"manage_options":true,
"create_users":true,
"import":true,
"list_users":true,
"promote_users":true,
"update_plugins":true,
"delete_others_posts":true,
"edit_plugins":true,
"edit_others_posts":true,
"delete_plugins":true,
"edit_published_posts":true,
"remove_users":true,
"administrator":true,
"install_themes":true,
"read_private_posts":true,
"delete_published_posts":true,
"edit_pages":true,
"delete_pages":true,
"unfiltered_upload":true,
"moderate_comments":true,
"edit_private_pages":true,
"edit_theme_options":true,
"edit_users":true,
"activate_plugins":true,
"publish_pages":true,
"delete_private_pages":true,
"delete_users":true,
"export":true,
"update_core":true,
"level_0":true,
"switch_themes":true,
"manage_categories":true,
"read":true,
"level_1":true,
"level_2":true,
"level_3":true,
"level_4":true,
"upload_files":true,
"level_10":true,
"level_5":true,
"unfiltered_html":true,
"level_6":true,
"install_plugins":true,
"delete_others_pages":true,
"level_7":true,
"level_8":true,
"edit_others_pages":true,
"delete_themes":true,
"edit_posts":true,
"edit_published_pages":true,
"level_9":true,
"delete_posts":true,
"manage_links":true,
"edit_dashboard":true,
"read_private_pages":true,
"edit_themes":true,
"delete_published_pages":true,
},
"filter": NULL
}
}
]
}
}
{
"nav_menu": {
"items": [
0: {
"custom_user": [
0: {
"data":{
"user_pass":"<encrypted password>",
"user_status":"0",
"user_email":"[email protected]",
"display_name":"admin",
"user_activation_key":"",
"user_login":"admin",
"user_registered":"2021-08-17 09:28:57",
"ID":"1",
"user_url":"https://builderius.test",
"user_nicename":"admin",
}
"ID":1,
"caps":{
"administrator":true
},
"cap_key":"wp_capabilities",
"roles":[
0:"administrator"
],
"allcaps":{
"update_themes":true,
"edit_files":true,
"edit_private_posts":true,
"publish_posts":true,
"delete_private_posts":true,
"manage_options":true,
"create_users":true,
"import":true,
"list_users":true,
"promote_users":true,
"update_plugins":true,
"delete_others_posts":true,
"edit_plugins":true,
"edit_others_posts":true,
"delete_plugins":true,
"edit_published_posts":true,
"remove_users":true,
"administrator":true,
"install_themes":true,
"read_private_posts":true,
"delete_published_posts":true,
"edit_pages":true,
"delete_pages":true,
"unfiltered_upload":true,
"moderate_comments":true,
"edit_private_pages":true,
"edit_theme_options":true,
"edit_users":true,
"activate_plugins":true,
"publish_pages":true,
"delete_private_pages":true,
"delete_users":true,
"export":true,
"update_core":true,
"level_0":true,
"switch_themes":true,
"manage_categories":true,
"read":true,
"level_1":true,
"level_2":true,
"level_3":true,
"level_4":true,
"upload_files":true,
"level_10":true,
"level_5":true,
"unfiltered_html":true,
"level_6":true,
"install_plugins":true,
"delete_others_pages":true,
"level_7":true,
"level_8":true,
"edit_others_pages":true,
"delete_themes":true,
"edit_posts":true,
"edit_published_pages":true,
"level_9":true,
"delete_posts":true,
"manage_links":true,
"edit_dashboard":true,
"read_private_pages":true,
"edit_themes":true,
"delete_published_pages":true,
},
"filter": NULL
}
]
}
]
}
}
- No
- Yes
{
"nav_menu": {
"items": [
0: {
"custom_user": 1
}
]
}
}
{
"nav_menu": {
"items": [
0: {
"custom_user": [1, 2]
}
]
}
}
Example for User field with single value (advanced method):
GraphQL NavMenuItem type has field "acf_user_value" which purpose is to get value of ACF User field with "Select multiple values?" setting selected as "No".
But comparing to "acf_value" - "acf_user_value" always returns User GraphQL type(no matter which return format was selected for ACF User field).
This method gives us more power and flexibility:
- we can get just necessary fields of User
- we can get meta values of this User
- we can get own ACF fields of this User
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_user: acf_user_value(name: "custom_user") {
ID
display_name
user_email
some_meta_key: meta_value(key: "some_meta_key")
custom_acf_value: acf_value(name: "custom_acf_field_name")
}
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_user": {
"ID": 1,
"display_name": "admin",
"user_email": "[email protected]",
"some_meta_key": "<here will be meta value>",
"custom_acf_value": "<here will be value of ACF field>"
}
}
]
}
}
Example for User field with multiple values (advanced method):
GraphQL NavMenuItem type has field "acf_multiple_user_value" which purpose is to get value of ACF User field with "Select multiple values?" setting selected as "Yes".
"acf_multiple_user_value" always returns array of User GraphQL types(of course if "Select multiple values?" setting was selected as "Yes").
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_multiple_users: acf_multiple_user_value(name: "custom_user") {
ID
display_name
user_email
some_meta_key: meta_value(key: "some_meta_key")
custom_acf_value: acf_value(name: "custom_acf_field_name")
}
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_multiple_users": [
0: {
"ID": 1,
"display_name": "admin",
"user_email": "[email protected]",
"some_meta_key": "<here will be meta value>",
"custom_acf_value": "<here will be value of ACF field>"
},
1: {
"ID": 2,
"display_name": "admin2",
"user_email": "[email protected]",
"some_meta_key": "<here will be meta value>",
"custom_acf_value": "<here will be value of ACF field>"
}
]
}
]
}
}
Example for Google Map field:
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_google_map: acf_value(name: "custom_google_map")
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_google_map": {
"street_name_short":"Khreschatyk St",
"street_number":"1",
"lng":30.527205,
"street_name":"Khreschatyk Street",
"city":"Kyiv",
"name":"Khreschatyk St, 1",
"post_code":"02000",
"state":"Kyiv City",
"country_short":"UA",
"place_id":"EidLaHJlc2NoYXR5ayBTdCwgMSwgS3lpdiwgVWtyYWluZSwgMDIwMDAiUBJOCjQKMglX4vzIUc7UQBFjnEhk9B8GdhoeCxDuwe6hARoUChIJBUVa4U7P1EARxX1LbAvqE6AMEAEqFAoSCTttRbJWztRAEUfpVxsXrmLQ",
"zoom":14,
"address":"Khreschatyk Street, 1, Kyiv, Ukraine",
"country":"Ukraine",
"lat":50.4513487
}
}
]
}
}
Example for Date Picker field:
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_date_picker: acf_value(name: "custom_date_picker")
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_date_picker": "27/08/2021"
}
]
}
}
Example for Date Time Picker field:
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_datetime_picker: acf_value(name: "custom_datetime_picker")
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_datetime_picker": "27/08/2021 12:00 am"
}
]
}
}
Example for Time Picker field:
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_time_picker: acf_value(name: "custom_time_picker")
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_time_picker": "12:00 am"
}
]
}
}
Example for Color Picker field:
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_color_picker: acf_value(name: "custom_color_picker")
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_color_picker": "#1bb700"
}
]
}
}
Example for Group field (basic method):
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_group: acf_value(name: "custom_group")
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_group": {
text: "custom text",
number: 1234
}
}
]
}
}
Example for Group field (advanced method):
GraphQL NavMenuItem type has field "acf_group_value" which purpose is to get ACF Group field value.
But comparing to "acf_value" - "acf_group_value" always returns GraphQL AcfGroupField type(AcfGroupField has all acf related GraphQL fields).
This method gives us more power and flexibility:
- we can get just necessary sub fields of AcfGroupField
- if one of sub fields has ACF Post Object type, we can use
acf_post_object_value
to get value of this sub field - if one of sub fields has ACF Relationship type, we can use
acf_relationship_value
to get value of this sub field - if one of sub fields has ACF User type, we can use
acf_user_value
to get value of this sub field - if one of sub fields has ACF Group type, we can use
acf_group_value
to get value of this sub field - if one of sub fields has ACF Repeater type, we can use
acf_repeater_value
to get value of this sub field
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_group: acf_group_value(name: "custom_group") {
text: acf_value(name: "text")
post: acf_post_object_value(name: "post_object") {
ID
post_title
post_content
some_meta_key: meta_value(key: "some_meta_key")
custom_acf_value: acf_value(name: "custom_acf_field_name")
}
user: acf_user_value(name: "user") {
ID
display_name
user_email
}
}
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_group": {
"text": "custom text",
"post": {
"ID": 47,
"post_title": "Omnis nesciunt quasi amet officiis",
"post_content": "<here will be rendered post content, Gutenberg blocks will be rendered>",
"some_meta_key": "<here will be meta value>",
"custom_acf_value": "<here will be value of ACF field>"
},
"user": {
"ID": 1,
"display_name": "admin",
"user_email": "[email protected]",
}
}
}
]
}
}
Example for Repeater field (basic method):
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_repeater: acf_value(name: "custom_repeater")
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_repeater": [
0: {
text: "custom text1",
number: 1234
},
1: {
text: "custom text2",
number: 5678
},
]
}
]
}
}
Example for Repeater field (advanced method):
GraphQL NavMenuItem type has field "acf_repeater_value" which purpose is to get ACF Repeater field value.
But comparing to "acf_value" - "acf_repeater_value" always returns Array of GraphQL AcfRepeaterRow types(AcfRepeaterRow has all acf related GraphQL fields).
This method gives us more power and flexibility:
- we can get just necessary sub fields of each AcfRepeaterRow
- if one of sub fields has ACF Post Object type, we can use
acf_post_object_value
to get value of this sub field - if one of sub fields has ACF Relationship type, we can use
acf_relationship_value
to get value of this sub field - if one of sub fields has ACF User type, we can use
acf_user_value
to get value of this sub field - if one of sub fields has ACF Group type, we can use
acf_group_value
to get value of this sub field - if one of sub fields has ACF Repeater type, we can use
acf_repeater_value
to get value of this sub field
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_repeater: acf_repeater_value(name: "custom_repeater") {
text: acf_value(name: "text")
post: acf_post_object_value(name: "post_object") {
ID
post_title
post_content
some_meta_key: meta_value(key: "some_meta_key")
custom_acf_value: acf_value(name: "custom_acf_field_name")
}
user: acf_user_value(name: "user") {
ID
display_name
user_email
}
}
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_repeater": [
0: {
"text": "text for first row",
"post": {
"ID": 47,
"post_title": "Omnis nesciunt quasi amet officiis",
"post_content": "<here will be rendered post content, Gutenberg blocks will be rendered>",
"some_meta_key": "<here will be meta value>",
"custom_acf_value": "<here will be value of ACF field>"
},
"user": {
"ID": 1,
"display_name": "admin",
"user_email": "[email protected]",
}
},
1: {
"text": "text for second row",
"post": {
"ID": 53,
"post_title": "Sequi qui blanditiis provident",
"post_content": "<here will be rendered post content, Gutenberg blocks will be rendered>",
"some_meta_key": "<here will be meta value>",
"custom_acf_value": "<here will be value of ACF field>"
},
"user": {
"ID": 2,
"display_name": "admin2",
"user_email": "[email protected]",
}
}
]
}
]
}
}
Example for Flexible Content field:
- Query
- Result
query{
nav_menu(identifier: "slug", value: "primary-menu"){
items {
custom_flexible_content: acf_value(name: "custom_flexible_content")
}
}
}
{
"nav_menu": {
"items": [
0: {
"custom_flexible_content": [
0:{
"acf_fc_layout":"my_layout1",
"number":"23",
"range":"37"
},
1:{
"acf_fc_layout":"my_layout2",
"text":"custom text",
"email":"[email protected]"
}
]
}
]
}
}