Adding Additional Menu in Wordpress Site

deitercat2
deitercat2 used Ask the Experts™
on
I am trying to add an additional menu above Main Navigation in the header of my Wordpress site.

Currently I have the following Code in my functions.php...

----------------------------
/*Top Menu Navigation */

register_nav_menu( 'topnav', __( 'Top Nav Menu', 'customizr' ) );


/* Main Menu Navigation */

add_filter('tc_menu_display', 'acub_menu_display');
function acub_menu_display($output) {
    echo preg_replace('| class="dropdown-toggle" data-toggle="dropdown" data-target="#"(.+?)<b |', ' class="a-stripped" $1</a><a href="#" class="dropdown-toggle a-caret" data-toggle="dropdown" data-target="#"><b ', $output, -1);
      
    }

----------------------------

I have the following code in my header.php, and I see the menu items above all pages including the dashboard and it breaks my wordpess administration pages.


wp_nav_menu( array( 'theme_location' => 'topnav', 'container_class' => 'topnav-menu' ) );

I am not yet comfortable working with PHP.

Here is the placement in my code.

<!DOCTYPE html>
<!--[if IE 7]>
<html class="ie ie7" <?php language_attributes(); ?>>
<![endif]-->
<!--[if IE 8]>
<html class="ie ie8" <?php language_attributes(); ?>>
<![endif]-->
<!--[if !(IE 7) | !(IE 8)  ]><!-->
<html <?php language_attributes(); ?>>                          
<!--<![endif]-->
<?php tc__f('rec' , __FILE__ , __FUNCTION__ ); ?>

      <?php do_action( '__before_body' ); ?>

      <body <?php body_class(); ?> itemscope itemtype="http://schema.org/WebPage">
            
            <?php do_action( '__before_header' ); ?>

 wp_nav_menu( array( 'theme_location' => 'topnav', 'container_class' => 'topnav-menu' ) );

               <header class="tc-header clearfix row-fluid" role="banner">
                  
                  <?php do_action( '__header' ); ?>

            </header>

            <?php
             //This hook is filtered with the slider
            do_action ( '__after_header' )
            ?>
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
James RodgersWeb Applications Developer

Commented:
it is breaking your layout due to being processed for the nav bar.

why are you pushing it through tc_menu_display? it is not necessary.

what is it you want to do?see on output?

Author

Commented:
I want the additional nav bar to appear above/ before the main menu navigation,

I want something similar to the sub navigation on  this site: http://www.solarvac.com.au/new/
except I want the additional nav on the top.
James RodgersWeb Applications Developer

Commented:
just take out the filter, what you see on that site is just a menu with a different style
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

Author

Commented:
Ok, I have gone back to the beginning.  I have stripped out everything and placed

register_nav_menu( 'topnav', __( 'Top Nav Menu', 'customizr' ) ); into my functions.php.


So my question is what should I have in my header.php and where should I place it so that the menu appears before the header menu.

I have not made changes in my header.php file it is the same as what is above.

Thank you.
Web Applications Developer
Commented:
above the header menu add this

 wp_nav_menu( array( 'theme_location' => 'topnav', 'container_class' => 'topnav-menu' ) );

that's it

I have used this same code to have multiple menus in a header

Author

Commented:
I appreciate your help.  Thanks for you patience.
James RodgersWeb Applications Developer

Commented:
did it work?

Author

Commented:
It worked and is now showing up at the top of my pages but I placed it in the functions.php file.   The menu is also showing at the top of all my dashboard pages.
James RodgersWeb Applications Developer

Commented:
ok try this


if(! is_admin()){

put menu code here
}

Author

Commented:
That worked.  Thank you again.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial