Front-End & Daily

How to retrieve items entered in the menu with Advanced Custom Fields

How to retrieve items entered in the menu with Advanced Custom Fields

Here's how to retrieve items using `get_field()` when using the WordPress plugin 'Advanced Custom Fields' with custom menus.

Table of Contents

What I want to do

Set the display condition for Advanced Custom Fields to 'Menu'

Advanced Custom Fields: Display condition for this field group is Menu

Enter values into the custom fields of the relevant menu

Advanced Custom Fields Menu Custom Fields

Here's how to retrieve these values within your theme files.

How to retrieve items

I was able to retrieve it by adding the prefix menu_ to the second argument of `get_field`.

get_field('key', 'menu_' . $menu_id);

For example, if you want to retrieve the value of the custom field 'copyright' for a menu named 'footer', do this:

$menu_id = wp_get_nav_menu_object('footer')->term_id;
get_field('copyright', 'menu_' . $menu_id);

Comments

After reviewing the content, we will publish it, omitting any personal information.

Enter your name and email address

Please enter if you would like a reply by email.

Personal information provided will not be disclosed. It will only be used for replies.

It will be sent directly. Please confirm and click 'Send'.

If this was helpful, we'd appreciate your support!
All support received will go toward my child’s upbringing.

Author's Baby Registry (Amazon)

Support me via OFUSE

Or support me by buying something through the buttons below
(You don't have to buy the specific item on the linked page.)

Support me via Amazon

Support me via Rakuten

Support me via Yahoo!Shopping

PR

As an Amazon Associate, Ken earns from qualifying purchases.

Share

Share on Twitter Share on Facebook Share on LINE Share on Hatena Bookmark