How to add specific menu on a specific page or pages

I’m looking for help on how to add specific menu on a specific page or pages with no plugin.

I know how to add and register a new menu like this:

//* Register third navigation menu position
function register_additional_menu() {
  register_nav_menu( 'third-menu' ,__( 'Third Navigation Menu' ));
}
add_action( 'init', 'register_additional_menu' );
add_action( 'genesis_before_content', 'add_third_nav_genesis' );

function add_third_nav_genesis() {
    echo'<div class="osastot-valikko">';
    wp_nav_menu( array( 'theme_location' => 'third-menu', 'container_class' => 'genesis-nav-menu js-superfish sf-js-enabled sf-arrows' ) );
    echo'</div>';
}

I would like to have a navigation menu named “Extra Menu” displayed only on three pages (post=6, post=7, post=8). What should I write in my function.php

Thanks!

2 Answers
2

Pages can have a specific template, so just create a new template and add the Menu on it.

You can copy the code on pages.php(this is the default page template) of you theme and paste on a new file (like “template-page-with-menu.php”). On the top of the code you must add the Template Name:

<?php /* Template Name: Page with Menu */ ?>

Then select this template on the pages that you want it.

enter image description here

Leave a Comment