Skip to main content

Nav Menus

Examples

How to get any nav menu data PRO FEATURE

query {
some_menu: nav_menu(identifier: "ID", value: 1) {
name
items {
title
url
type
children {
title
url
type
}
}
}
}
info

identifier argument can accept "ID" or "slug" or "name" or "[[global data variable]]" or "{{local data variable}}".

value argument is required.

How to get all nav menus data PRO FEATURE

query {
nav_menus {
name
items {
title
url
type
children {
title
url
type
}
}
}
}

How to get output of any php function with arguments based on every nav menu item in nav menu PRO FEATURE

If we need for example to get output of function get_post_meta for every nav menu item in nav menu, we can do it in this way:

query {
nav_menu(identifier: "ID", value: 1) {
items {
id: ID
title
url
color: php_function_output (
function: "get_post_meta",
arguments: [
"{{id}}",
"color",
true
]
)
}
}
}
info

In this example for every post we used local data variable id - it is ID field of nav menu item but aliased like id. ::::