WordPress.org

Forums

Adamos
Second menu to specific page (4 posts)

  1. nick853c
    Member
    Posted 1 year ago #

    Hi.

    Im am building this site: http://nick853c.mmd.eal.dk/4sem/wordpress/

    I would like to have a menu that will only appear on specific pages below the header menu. It should be horizontal.

    Any ideas?!

    Thank you.

  2. Sprytechies
    Member
    Posted 1 year ago #

    first registered custom menu if you developed in functions.php
    for example:-
    //register the custom menus

    function register_my_menus() {
    register_nav_menus(
    array(
    'profile-menu' => __( 'Profile Menu' )
    'services-menu' => __( 'Services Menu' )
    )
    );
    }
    add_action( 'init', 'register_my_menus' );

    then on specific or desired page user this code for example:-

    <?php
    if (is_page('profile')){
    wp_nav_menu(array('menu'=>'profile-menu' ));
    } elseif (is_page('services')) {
    wp_nav_menu(array('menu'=>'services-menu' ));
    }

    ?>

  3. nick853c
    Member
    Posted 1 year ago #

    Is there any other way?
    Is seems like the theme won't accept the function, and the editer f****s up.

    This line:
    function register_my_menus()

    It isnt in the theme function.php and when i add it the pages just turns all white.

    Thanks.

  4. Sprytechies
    Member
    Posted 1 year ago #

    this is the custom function for creating own custom menu, this is not wordpress function so editor don't shows it :)

    <?php
    if (is_page('your specific page name')){
    wp_nav_menu(array('menu'=>'your desired menu to show up on the page' ));
    }
    ?>

    put this is code into appropriate template file which is responsible for the showing your specific code... have fun

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic