I'm trying to swap out the main menu of a page if it uses a specific page template.
This was working perfectly until I added a 2nd menu to the page.
I would greatly appreciate any guidance on how to target only the primary-menu and not all the menus on the page. I tried 'primary-menu' but did not work.
In functions.php:
add_filter('wp_nav_menu_args', function ($args) {
if (is_page_template('page-template-custom.php')) {
$args['menu'] = 'custom-menu';
}
return $args;
});
Thanks very much!