0

Below code is a portion of my "wp_nav_menu" code. I don't understand why the 4th part below, the 'menu' section breaks the "customizer refresh". It makes the refresh in customizer not function when editing menus. But if I delete the 'menu' line completely, then the customizer functions normal/perfect. Fine with me, I will delete it. But can someone explain why the line breaks the customizer refresh?

    wp_nav_menu( array(
    'container'       => 'nav',
    'container_id'    => 'site-navigation',
    'container_class' => 'main-navigation',
    'menu'            => 'primary',

1 Answer 1

0

The menu argument is used to output a particular menu item to a particular location in the theme.

Suppose you created and a menu in the Dashboard and want it to load in the main navigation bar without setting it in the 'Manage Locations' tab in the Dashboard. In that case, you will enter the menu ID/name/slug/object in the menu argument of wp_nav_menu. Check out the codex - https://developer.wordpress.org/reference/functions/wp_nav_menu/

The theme_location will be ignored in this case.

Regarding your issue, you have entered 'primary' in the menu argument. You need to verify if any of the menus you created have 'primary' as slug or name.

3
  • Thanks. Yes I confirm the info. I tried using the actual menu name that is saved in the name section of the wp menu and I also tried using the location name. Neither function, they break the customizer refresh and don't display edits. It seems I am missing some needed name config in the customizer.php maybe. Still trying to solve this.
    – Angel Hess
    Aug 16, 2021 at 19:22
  • I do notice many examples written and they leave the menu part empty. Is it normal to be empty? I would like to have it not empty just because that is what I am thinking. What is normal?
    – Angel Hess
    Aug 16, 2021 at 19:23
  • Yes, it's normally not used. Instead, the 'theme_location' argument is used so that users have the power to set the menu themselves. Aug 17, 2021 at 3:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.