Replace primary menu

Hello all,

I'm trying to completely replace the primary menu in a specific page template, but so far I've been unable to succeed. Here are both solutions I've tried:

beans_modify_action_callback( 'beans_primary_menu', function() {
  <code to generate new menu here>
add_filter( 'beans_primary_menu_args', function($args) {
    if (has_nav_menu( 'training' )) {
      $args['theme_location']  = 'new-menu';
    }                                                                                                                                                              return $args;

Can someone put me on the right track, I'm stuck.

Hey Mark,

You shouldn't need to modify the callback. All you need is to alter the theme_location which you almost got right. You need to make sure that you have return $args; in your beans_primary_menu_args callback function (after the if statement).

If you are using the offcanvas menu on mobile, make sure that you apply the change onto the beans_primary_offcanvas_menu_args filter too 😉

Happy coding,

Can primary menu be set to offcanvas menu by default? side menu instead of header .

Write a reply

Login or register to write a reply, it's free!