DEV Community

Cover image for Wordpress add menu in footer
Chetan Rohilla
Chetan Rohilla

Posted on • Edited on • Originally published at w3courses.org

Wordpress add menu in footer

In wordpress we can create our custom menu and can place at any place in our wordpress website.

First of all paste this code in your functions.php file located at website_root_path/wp-content/themes/your_theme/functions.php

register_nav_menus( array(
    'secondary' => __( 'Footer Menu', 'generatepress' ),
) );
Enter fullscreen mode Exit fullscreen mode

generatepress’ is your theme name and ‘Footer Menu’ is your menu name. You can name it whatever you want and ‘secondary’ is the menu id you can also name it whatever you want.

Now open your wordpress dashboard and navigate to Appearance -> Menus and add your menu items to the Menu you have created.

Now we will show the our menu in wordpress theme let say we want to show menu in footer. Then we will paste the code given below to our footer.php file located at website_root_path/wp-content/themes/your_theme/footer.php

wp_nav_menu( array( 
    'theme_location' => 'secondary', 
    'container_class' => 'footer-menu-class' ) );
Enter fullscreen mode Exit fullscreen mode

In the code above ‘secondary’ is the menu id. And we have added in register_nav_menus ‘footer-menu-class’ is the class of our menu container used to styling or adding css to our menu. There are also many options to our function wp_nav_menu.


Please like share subscribe and give positive feedback to motivate me to write more for you.

For more tutorials please visit my website.

Thanks:)
Happy Coding:)

Top comments (0)