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
- Problem with serialized arrays in custom meta
- explode array within shortcode
- Can I count the number of users matching a value in a multiple value key?
- How to delete custom field “suggestions” from dropdown list
- How to get a meta value from all post
- Adding existing user custom field value to a woocommerce product [closed]
- How to save values of a custom input field on the Network > Site Info screen
- How to load php file for specific page in admin?
- How to set default metaboxes on user creation?
- ajax jquery update custom field meta value front end
- Add input field to ‘Pages > Edit Page’ through functions.php
- get_post_meta not working inside loop
- How do I exclude posts by custom field value?
- Upcoming Event: How do I sort database by custom date field, but ignore past dates?
- Auto populate a meta box field from another meta box field when publish or save
- Eliminating the appearance of a specific custom field in a post
- Conditional custom field query
- Display two custom values from a post
- Find page IDs with specific meta tag key value pairs
- Order query by meta_value with multiple custom fields
- Display only past events on that page using Visual Composer Grid Bulider
- user Profile meta value as custom field
- Send email with custom fields after new draft is saved or new post published
- Better way to save image in custom field
- Removing link ” from ” on meta_value in custom feilds
- Jetpack post types Portfolio or Testimonials support for custom fields?
- Merge Multiple Custom Fields into one New Custom Field for Searching
- Is there a better way to list all database terms alphabetically?
- filter custom field values $min $max
- Select multiple images from custom field
- Custom Fields – How to create a list from multi-line entries of a single value
- Unique meta_key with array value vs repeated meta_key with single values
- custom field (video/audio url) and embed functionality
- Allow only one post with specific meta value
- Querying posts by latitude and longitude to build a Google Maps with several markers
- How to display childrens custom fields?
- Attach images to posts using custom fields (just paths to images already uploaded)
- how to display custom fields of post on a web page
- Changed PHP handler to DSO – weird custom fields problem [closed]
- How to fill custom fields with brackets in their key with add_post_meta()?
- Front-End User Profile
- Displaying pages with a specific custom meta
- How to update user profile custom fields
- How to validation for sanitize_URL?
- How can I output the custom fields wrapping with HTML
- put saved metabox values back into fields and then display on the front end
- How to get custom image field of specific post id
- Custom field to array?
- How to sort by custom field value?
- How to update custom field of a posts in a particular category
- How to query posts by month based on date custom field?
- Change word in woocommerce product category custom field
- get posts based on non-single metadata
- Problem with revisions only returning four results
- Convert author metadata to a custom field
- How to save multiple values with same meta_key, each value linked to another tag id
- Add forms dynamically in admin pages?
- Custom pages or Custom Posts
- get_avatar filter is not working as per requirement
- What WordPress “technology” would I use if I wanted subscribers to be able to mark pages with characteristics and notes?
- WordPress Admin – Automatically Sort Custom Posts by Custom Field Date Value in d-m-Y Fomat
- how can i show WordPress custom field data to my short code?
- searching by keywords in post’s metas or pagination links problem
- Permanently show Custom Fields in Editor
- open modal window
- a lot of custom fields
- Hide custom fields by user’s role
- select user with all meta field and field value. I am use Below Query for this ,So any of know another way to fast query instead of below query?
- Retrieve Google API JSON data and store as WordPress Custom Fields
- update meta field value after
- meta_query ‘compare’ => ‘!=’ not working
- If metabox fields has content display content
- Display Data From This Custom Media Upload Meta Box?
- Custom fields and auto save
- Save values generated via API as custom meta fields
- Load code for custom fields only on admin pages?
- Pagination not displaying correct number of pages
- Add fields to edit in custom widget
- save all acf options in one meta_value [closed]
- Can running a WP-Cron to update_post_meta cause performance issues?
- custom field value is blank or empty
- How to add a custom field to the comments “Quick Edit” screen?