WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Display title custom menu? (6 posts)

  1. wzshop
    Member
    Posted 2 years ago #

    Hi guys,
    Is it possible to show the title of a custom menu on the front-end?

    I now have this code which only shows the items:
    <?php wp_nav_menu( array( 'theme_location' => 'header' ) ); ?>

    How to also display the title of the menu?
    Thanks!

  2. keesiemeijer
    moderator
    Posted 2 years ago #

    Try it whith this:

    <?php
    $menu_location = 'header';
    $menu_locations = get_nav_menu_locations();
    $menu_object = (isset($menu_locations[$menu_location]) ? wp_get_nav_menu_object($menu_locations[$menu_location]) : null);
    $menu_name = (isset($menu_object->name) ? $menu_object->name : '');
    
    echo esc_html($menu_name);
    ?>
  3. wzshop
    Member
    Posted 2 years ago #

    Thank you, that worked.

    So your code should be added to mine right? It is not possible to use the wp_nav_menu array for the Title and the Items?

    Thanks a lot!

  4. keesiemeijer
    moderator
    Posted 2 years ago #

    It is not possible to use the wp_nav_menu array for the Title and the Items?

    Do you want the title inside the menu? Not sure what you want.

    maybe this: http://codex.wordpress.org/Function_Reference/wp_nav_menu#Adding_a_Word_at_the_Beginning_of_the_Menu

  5. wzshop
    Member
    Posted 2 years ago #

    Yeah found that already. Anyway i got it. So many thanks (Y)

  6. keesiemeijer
    moderator
    Posted 2 years ago #

    You're welcome. Glad you got it resolved

Topic Closed

This topic has been closed to new replies.

About this Topic