Since Centum uses a dual-menu system and causes residual styling with the menu, we’ll use Manual Integration to replace the theme’s menu system.
Manual Integration
1. Copy the header.php
to a child theme
We’ll be editing the theme’s header.php
. Copy this file into a child theme (create one if you don’t have one already) and edit it there so that your changes are preserved when updating the theme in the future.
2. Find the theme’s navigation system
The theme’s navigation system is toward the end of the header.php
and looks like this:
<div id="navigation"> <?php $menu = wp_nav_menu( array( 'theme_location' => 'mainmenu', 'echo' => 0, 'menu_class' => 'dropmenu main-menu', 'container_id' => 'mainmenu-cont', 'fallback_cb' => 'magnovus_menu_fb') ); $menu = str_replace("\n", "", $menu); $menu = str_replace("\r", "", $menu); echo $menu; ?> <?php wp_nav_menu(array( 'theme_location' => 'mainmenu', 'walker' => new Walker_Nav_Menu_Dropdown(), 'items_wrap' => '<select class="selectnav"><option value="/">'.__('Select Page','purepress').'</option>%3$s</select>', 'container' => false, 'menu_class' => 'selectnav', )); ?> <!-- Search Form --> <?php if(ot_get_option('centum_search') != "disable") { ?> <div class="search-form"> <form action=" <?php echo home_url(); ?> " id="searchform" method="get"> <input type="text" class="search-text-box" name="s"> </form> </div> <?php } ?> </div>
This code will end up in our else
statement when we conditionally replace the menu.
3. Replace the menu
Replace the theme’s menu code in the child theme’s header.php
conditionally with the manual integration code generated in the Control Panel
<?php if( function_exists( 'ubermenu' ) ): ?> <?php ubermenu( 'main' , array( 'theme_location' => 'mainmenu' ) ); ?> <?php else: ?> <div id="navigation"> <?php $menu = wp_nav_menu( array( 'theme_location' => 'mainmenu', 'echo' => 0, 'menu_class' => 'dropmenu main-menu', 'container_id' => 'mainmenu-cont', 'fallback_cb' => 'magnovus_menu_fb') ); $menu = str_replace("\n", "", $menu); $menu = str_replace("\r", "", $menu); echo $menu; ?> <?php wp_nav_menu(array( 'theme_location' => 'mainmenu', 'walker' => new Walker_Nav_Menu_Dropdown(), 'items_wrap' => '<select class="selectnav"><option value="/">'.__('Select Page','purepress').'</option>%3$s</select>', 'container' => false, 'menu_class' => 'selectnav', )); ?> <!-- Search Form --> <?php if(ot_get_option('centum_search') != "disable") { ?> <div class="search-form"> <form action=" <?php echo home_url(); ?> " id="searchform" method="get"> <input type="text" class="search-text-box" name="s"> </form> </div> <?php } ?> </div> <?php endif; ?>