user3877230
user3877230

Reputation: 457

Create own footer menu in Wordpress?

I do have two menus in my Wordpress-Page which are called

Mainmenu(Primary Menu)
Footer

I associated the "Mainmenu" to the header of the website. I want the footer of the Wordpresspage to look exactly like the header, only difference should be the Links in it. It should not be taken from the "Mainmenu", but from the menu called "Footer". The function of the Header looks like this:

echo '<nav id="rtp-primary-menu" role="navigation" class="rtp-nav-wrapper' . apply_filters( 'rtp_mobile_nav_support', ' rtp-mobile-nav' ) . '">';
rtp_hook_begin_primary_menu();

/* Call wp_nav_menu() for Wordpress Navigaton with fallback wp_list_pages() if menu not set in admin panel */
if ( function_exists( 'wp_nav_menu' ) && has_nav_menu( 'primary' ) ) {
    wp_nav_menu( array( 'container' => '', 'menu_class' => 'menu rtp-nav-container clearfix', 'menu_id' => 'rtp-nav-menu', 'theme_location' => 'primary', 'depth' => apply_filters( 'rtp_nav_menu_depth', 4 ) ) );
} else {
    echo '<ul id="rtp-nav-menu" class="menu rtp-nav-container clearfix">';
    wp_list_pages( array( 'title_li' => '', 'sort_column' => 'menu_order', 'number' => '5', 'depth' => apply_filters( 'rtp_nav_menu_depth', 4 ) ) );
    echo '</ul>';
}

rtp_hook_end_primary_menu();
echo '</nav>';

The Theme i am using is rtPanel. Can anyone tell me how i simply can change this function in the way that it will load its content from the Menu called "Footer" and not from the Primary Menu which is "Mainmenu"?

Please dont worry about the CSS and everything, i will take care about this. I really just want to now how i have to change this function to load the "Footer"-Menu in it and not the Primary-Menu(Mainmenu).

As an Attachment how it look in the menu:

enter image description here

Thank you very much advance!

Upvotes: 0

Views: 1064

Answers (1)

maksbd19
maksbd19

Reputation: 3830

This is really simple, in fact when you start developing wordpress theme this might be one of the very first items you need to learn.

You need to register a menu location for footer seciton. You can learn more in codex

 register_nav_menu( 'footer', __( 'Footer Menu', 'theme-slug' ) );

This will register the menu for you. Since you already have the menu location just find the location parameter. We're going to use that in the following code. For now assume it 'footer' like the above one. And the code for the footer menu according to your referenced code-

echo '<nav id="rtp-primary-menu" role="navigation" class="rtp-nav-wrapper' . apply_filters( 'rtp_mobile_nav_support', ' rtp-mobile-nav' ) . '">';
//rtp_hook_begin_primary_menu(); // we better disable this hook as it intends for the header primary menu

/* Call wp_nav_menu() for Wordpress Navigaton with fallback wp_list_pages() if menu not set in admin panel */
if ( function_exists( 'wp_nav_menu' ) ) {
    wp_nav_menu( array( 'container' => '', 'menu_class' => 'menu rtp-nav-container clearfix', 'menu_id' => 'rtp-nav-menu', 'theme_location' => 'footer', 'depth' => apply_filters( 'rtp_nav_menu_depth', 4 ) ) );
} else {
    echo '<ul id="rtp-nav-menu" class="menu rtp-nav-container clearfix">';
    wp_list_pages( array( 'title_li' => '', 'sort_column' => 'menu_order', 'number' => '5', 'depth' => apply_filters( 'rtp_nav_menu_depth', 4 ) ) );
    echo '</ul>';
}

//rtp_hook_end_primary_menu(); // we better disable this hook as it intends for the header primary menu
echo '</nav>';

Notice the theme_location parameter in wp_nav_menu() function? This is the one which plays behind to get you menu correctly.

Now play around with CSS and you might get what you intend.

Hope this might help you.

Upvotes: 1

Related Questions