Reputation: 11
I want to use 2 menu template on WordPress. First is a default template, and the second is a mega menu plugin.
To call the mega menu plugin template, use code like this:
<?php do_action('mega_menu'); ?>
The scenario is: when the plugin is not installed, then the default menu will display. I use this code:
<?php if(function_exists('main_nav')) { ?>
<?php do_action('mega_menu'); ?>
<?php } else if(function_exists('main_nav')) { ?>
<?php main_nav(); ?>
<?php } ?>
But unfortunately did not work. Really appreciate for any helps. Thanks in advance.
Upvotes: 1
Views: 71
Reputation: 5183
add_action('mega_menu','my_mega_menu'); // Add action hook `mega_menu` to your callback funciton `my_mega_menu`
function my_mega_menu(){ // callback function
wp_nav_menu( array('menu' => 'your mega menu name' )); // calling menu in callback fn
}
<?php if(function_exists('main_nav')) { ?>
<?php do_action('mega_menu'); ?> // calling hook `mega_menu`
<?php } else if(function_exists('main_nav')) { ?>
<?php main_nav(); ?>
<?php } ?>
Upvotes: 1