I wanna preview all the fields that the nav menu $item array holds. Is there a function to fetch it from anywhere and place it inside var_dump?
Leave a Reply
You must be logged in to post a comment.
I wanna preview all the fields that the nav menu $item array holds. Is there a function to fetch it from anywhere and place it inside var_dump?
You must be logged in to post a comment.
The items are set up in
wp_nav_menu()
. There is a useful filter you can use:'wp_nav_menu_objects'
. It offers the items as$sorted_menu_items
and the arguments of thewp_nav_menu()
call as$args
.From
wp-includes/nav-menu-template.php::wp_nav_menu()
:So â¦
$sorted_menu_items
unchanged andIn my following example I print the data on
'shutdown'
â thatâs the latest hook WordPress fires.If there is no nav menu â nothing happens. But if we could collect some data, we get a nice long list at the end of a document with all item properties we can use in other filters.