Hi all,
I’ve added a custom field to a menu (not to all items in the menu, just to the menu itself).
How can I display that field outside of the traditional wp_nav_menu()
call?
Is there something like get_field('field_name', $nav_menu_id);
that I can use?
Try one of these examples:
To get both field
and menu
<?php
$id = '' //(string) (required) Menu 'id','name' or 'slug'
$menu = wp_get_nav_menu_object( $id );
$field = get_field('field_name', $menu);
To get only the field
:
<?php
// WP < 4.4
$post_id = 'nav_menu_1' //the number must be the menu ID
// WP >= 4.4
$post_id = 'term_1' //the number must be the menu ID
$field = get_field('field_name', $post_id);
EDIT: Different calls for WP Versions