get_field() gets the field for the current post in the loop, but the loop isn’t used for menu items, so you need to specify which post you want to get the value from. In the case of menu items, each nav menu item is a WP_Post object, so you want to pass that:
foreach( $items as &$item ) {
$icon = get_field( 'icon', $item );
// etc.
}
Related Posts:
- How to add a custom field in the advanced menu properties?
- Adding a custom field to the site identity menu
- Add meta data to the menu
- Create a select drop down of available menus
- Dynamic User State & City selection
- Creating a custom menu/widget area
- Nav Menu – Add class based on meta keys
- Declaring in variables [closed]
- How to add a custom field in the advanced menu properties?
- Walker class for sub-menu with ACF fields
- Populate wordpress menu with link to custom field value (file download)
- Show Custom field value instead of title in WP Menu
- How to make menu country specific?
- How to check custom fields from functions.php
- Override edit_custom_walker.php to conditionally show input depending on menu position
- How to use page metadata while using wp_list_pages()?
- Add custom fields to specific menus
- Add CSS class to posts with certain meta key
- Where are custom field values stored in the database
- Using TinyMce with textareas in meta boxes on custom post types
- How to display all custom fields associated with a post?
- How can I fetch CSS from JSON WP REST API response
- ACF – get_field() using ‘option’ as post_id not working
- How to set a default meta value for custom field
- Populating meta box with select-list of existing posts, and assigning it to custom post types
- Create meta boxes that don’t show in custom fields
- How To Create a Metabox of HTML Content with Instructions For Editors When Editing a Post or Page?
- wp_editor in add_meta_boxes does not show gallery
- Calling Specific Pages with wp query Part II
- How do I assign this filter to a variable? (Appending php & markup to the_content)
- If value present, order posts by two consecutive custom fields
- Copying Custom Meta Values from existing post to a duplicate post
- Deleting a custom field field
- custom field to always to .get_the_title()?
- Displaying posts with only upcoming dates according their custom field date value
- How to filter a dd/mm/yyyy date from a custom field in a query
- How do I add custom_meta_box_id’s value?
- Get a post_id where meta_value equals something in a serialized meta_value field
- List posts with common custom field value
- Create Posts using Import>RSS/WXR/XML and pass values to Custom Fields
- Importing users to Buddypress with custom fields
- Including Database Generated Pages in Site Search [closed]
- Is it bad to use a lot of Custom Meta Fields?
- How to get customfield value by woocommerce product ID
- How do I get the url slug inside the dashboard for a custom post type?
- How to save media files under custom folder without changing wp-config.php or changing media settings
- How can I sort homepage by a meta value?
- Audio player shortcode not showing up when using variable
- get_posts that match a user-specified value on a page
- How to add image attachment to post from a single meta key (Woocommerce)
- Custom Fields – Taller editing area
- How to add Advenced Custom Fields In Single Post
- how to upload a image from frontend with wp_insert_post and also update_post_meta?
- Hide custom meta data if empty
- Advanced search for meta fields
- Woocommerce Product Custom Select List (not variation)
- How to find a post using XML-RPC without knowing ID
- Why orderbyb meta_value_num won’t affect the generated SQL Query order?
- I need a “Choose from existing content” popin
- For homepage images (for small business website), is it better to use custom fields or post_thumbnail?
- Sorting editor screen items
- get post id using custom filed value
- Query_posts with custom field meta value
- Passing meta_box string to post__in?
- Can data from a Custom Field data be used by a shortcode on a per page/post basis?
- How can I modify RSS item titles to be either the title or a custom meta field?
- Avoiding ACF get_field and returning to core WordPress function
- Move Title and the Content WYSIWYG editor position
- WordPress built in custom fields don’t validate or sanitize? Is there a way to fix this?
- How can I hide custom field from users used for caching response from external api?
- WordPress colorpicker save both hex and RGB
- Can’t get video meta from wp_read_video_metadata()
- Best way to contruct a global custom field?
- Diamond question mark in text after migrating content
- Display posts with empty custom field
- How to write specific HTML code with a specific custom field? [closed]
- How to style posts selecting a CSS post_class (added through custom_fields?)?
- Meta query relation ‘OR’ not working as expected
- How to hide custom fields added by a plugin?
- Add custom data (field) to sidebar widgets for later display
- Image upload and path to custom field
- Create a new custom field for all posts based on current custom field
- Display custom field only if it has a value
- Need to search a custom field (ingredients, one long string per post), but want it to allow phrases/non-exact matches
- Listing posts with a value in a custom field
- Using Customizer API vs Custom Meta Box for custom content
- How do I display an article using a WordPress custom field?
- WordPress admin area: select box with 12.000+ options
- Custom meta boxes – add php code inside?
- to create a custom post type with additionnal url field such as link to social network and an email field
- Query Multiple meta
- Display different category template if custom field is checked
- Show message if statement is false – foreach
- Order by custom field in query multiple
- Returning website screenshot based on Custom Field
- Echo text if field under user_meta is empty with get_users()
- Filtering posts by WORD in custom field
- Cannot Hide Google Map if custom field is blank
- Set new url from custom post field
- Set post status to draft after validating post meta values in save_post hook