Thanks John, that was it. It’s hard to search for this issue and find that help article, but I don’t know what I would suggest to make it more discoverable, either 🙂
Okay,
I played around some more, and this seems to be a bug/inconsistency related to the ambiguous ways you can call wp_nav_menu
, in particular the menu attribute you can pass in, which can be:
(int|string|WP_Term) Desired menu. Accepts (matching in order) id, slug, name, menu object.
Here the different output for different ways of calling my menu:
wp_nav_menu(array('menu' => 'Footer menu'));
results in print_r($args->menu)
:
stdClass Object ( [menu] => Footer menu [container] => div [container_class] => [container_id] => [menu_class] => menu [menu_id] => [echo] => 1 [fallback_cb] => wp_page_menu [before] => [after] => [link_before] => [link_after] => [items_wrap] =>
%3$s
[item_spacing] => preserve [depth] => 0 [walker] => [theme_location] => )
Where as this:
wp_nav_menu(array('menu' => 1));
results in print_r($args->menu)
:
stdClass Object ( [menu] => WP_Term Object ( [term_id] => 3 [name] => Footer menu [slug] => footer-menu [term_group] => 0 [term_taxonomy_id] => 3 [taxonomy] => nav_menu [description] => [parent] => 0 [count] => 1 [filter] => raw ) [container] => div [container_class] => [container_id] => [menu_class] => menu [menu_id] => [echo] => 1 [fallback_cb] => wp_page_menu [before] => [after] => [link_before] => [link_after] => [items_wrap] =>
%3$s
[item_spacing] => preserve [depth] => 0 [walker] => [theme_location] => ) MENUWP_Term Object ( [term_id] => 3 [name] => Footer menu [slug] => footer-menu [term_group] => 0 [term_taxonomy_id] => 3 [taxonomy] => nav_menu [description] => [parent] => 0 [count] => 1 [filter] => raw )
So apparently the menu will render with both methods, but the $args->menu
differs significantly, and in the string parameter variant does not result in the term object ACF is expecting. Hurray WordPress.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.