That's what we'll be targeting with our CSS later on. container_class is the CSS class that will be given to the container in which the menu is wrapped.The parameters are then wrapped in an array.wp_nav_menu() is the function that fetches a navigation menu and outputs it.Your function may look a little different depending on the parameters, but let's break down the example above and see what each element does: You should be able to find this line: wp_nav_menu( array( 'container_class' => 'main-nav', 'theme_location' => 'primary' ) ) In your theme, open up the header.php file. Instead, WordPress uses a PHP function to query the database and fetch navigation menu items, then display them in the correct structure.Įach item in your navigation menu is actually a post in the wp_posts table in your database-not a normal post, but a special kind of post that's used just for navigation menu items, with its own metadata including the text to be displayed and the target of the link. Unlike with static sites, menus aren't hard-coded into your site. The first thing you'll need to understand is how WordPress drop-down menus work. a theme you're coding yourself, or a child theme of a third-party theme if you want to modify the menuġ.a development installation of WordPress.To follow along with this tutorial, you'll need: What You'll Need to Create a Drop-Down Navigation Menu in HTML on WordPress Make your drop-down menu design mobile-friendly.
How to Make a Drop-Down Menu in WordPress If you'd rather watch our video on creating a drop-down menu in HTML for WordPress, just press play and get started. This will come in useful on more sites than you might imagine (not every site needs a fancy menu), and it will give you the foundation you need to start building more advanced menus. From burger menus for mobile through mega menus for stores to sticky menus for enhanced user experience, there's a great choice in the way you can present your navigation menu on your WordPress site.īut what if you want to create a straightforward drop-down menu for WordPress with a few top-level items and some more items that drop down from them when the user hovers over them?īefore you start getting into coding advanced menus like mega menus and burger menus, it's a good idea to learn how to create a drop-down menu. Navigation menus are having a bit of a moment in the spotlight.
Do you want to create a drop-down menu in WordPress? You've come to the right place! In this tutorial, I'll teach you how to create a professional drop-down menu design.