Home Forums Front-end Issues Get theme location from menu name?


Get theme location from menu name?

  • I have an ACF field that I’ve coded to dynamically populate any WordPress menus created. The field works great on the backend and I’m able to select the menu from a list of dropdowns, but I can’t get the chosen menu to display right on the front end. The menu in question is registered via code as:

    ‘social-menu’ => ‘Social Menu’

    However, the menu created in WordPress is called “Social Media” and has a slug of “social-media”. ACF is only returning these two values. I could just rename the menu so everything matches to “Social Menu”, but I don’t want my clients to have to specifically name menus to get this to work. So my question is:

    How do I get it to return the (1) theme location of the menu OR (2) get the theme location of a menu from the slug or title of that menu?

  • to display the menu selected you would call wp_nav_menu() with the menu slug

    wp_nav_menu(array('menu' => $slug));
  • I swear I tried that and it didn’t work before. Thank you!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.