1

I have this wp designed link where i have Home, Services, About, and Contact. Under Services i have separate menus like webdesign, webdevelopment, seo, maintenance and so on..

I have created the secondary nagivations in the menu page (Admin > Appearance > Menu). I have this code.

<?php wp_nav_menu( 
    array( 
        'theme_location' => 'secondary-menu', 
        'menu_class'     => 'secondary', 'fallback_cb' => ''
        )); 
?>

Where should I place this, because the pages.php is for all the pages.

  • So you have one primary menu and one secondary, and you want secondary menu to be on one specific page. Am I getting this correct? – Aniruddha Gawade Sep 13 '16 at 9:30
  • @AniruddhaGawade Yes, The secondary menu displays below the cover image. Iam using Bootstrap framework and the navbar stays on top and on the service page - below the cover image the secondary menu displays. – Dexter Sep 13 '16 at 9:34
  • In that case you'll have to create a separate template for that page. – Aniruddha Gawade Sep 13 '16 at 9:39
  • you mean one page like pages.php but this one is to target the service page alone. – Dexter Sep 13 '16 at 9:48
  • Yes. page-{page-slug}.php. This way you'll get code from this file to your page. – Aniruddha Gawade Sep 13 '16 at 9:53
0

If you need this menu on one page only, let's say About Us (slug: about-us), you can easily add a conditional like this in pages.php at the place where you want the menu to appear:

if (is_page('about-us')) {
  wp_nav_menu( 
    array( 
        'theme_location' => 'secondary-menu', 
        'menu_class'     => 'secondary', 'fallback_cb' => ''
        )); 
  }

Remember that if you have a third party theme, you should build a child theme for this page, because else your adaptation will be lost when the theme is updated.

  • Thank you!. There is no third party theme. New theme is created with Bootstrap framework as a base. – Dexter Sep 13 '16 at 9:58
  • This is what i added in the function - add_action( 'init', 'my_custom_menus' ); function my_custom_menus() { register_nav_menus( array( 'secondary-menu' => __( 'Services Page')));} and this is what i added in the page.php - <?php if (is_page('home')) {wp_nav_menu(array('theme_location' => 'Service Page', 'menu_class' => 'secondary', 'fallback_cb' => ''));}?>. I want to test it on the homepage first so i gave the slug as home. I cannot see anything. What iam missing. The menu name wp-secondary-menu in the appearance. – Dexter Sep 13 '16 at 10:18
  • It's working now. The menu went behind the navbar. – Dexter Sep 13 '16 at 10:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.