How to add a WordPress navigation menu to pages and posts

Introduction to WordPress Navigation Menus

Navigation menus are crucial elements in any website, as they provide users with an easy way to navigate between the different sections of your site. In WordPress, creating and managing menus is a process that you can easily do through the administration panel.

In this article, we will explore how to add a navigation menu to both WordPress pages and posts, ensuring that your content is accessible to all visitors.

Creating a Navigation Menu in WordPress

To start adding a navigation menu, you first need to create the menu from the WordPress dashboard. Let's follow these steps:

  • Log in to your WordPress administration panel.
  • Navigate to Appearance > Menus.
  • If you do not have a menu created, select create a new menu.

Configure the Menu

Once you have created the menu, it is time to configure it. You can add pages, entries, custom links and even categories to the menu. To do this:

  • In the Adding items to the menuSelect the pages or entries you want to include.
  • Click on Add to menu to include them.
  • Arrange the elements by dragging and dropping them in the order you prefer.

Assigning the Menu to a Location

After setting up the menu, you must assign it to a specific location in your theme. This ensures that it displays correctly on the website. WordPress themes usually offer several locations. To assign your menu:

  • Search for the section Set menu location.
  • Select the desired location for your menu (for example, Main menu).
  • Click on Save menu.
    How to add a WordPress navigation menu to pages and posts
    Download our web maintenance guide Free of charge!
    Free guide for freelancers and small businesses that want to avoid surprises and improve their web performance.

Add Menu in Pages and Entries

Once you have your menu created and assigned, you can add it to specific pages and posts using Gutenberg blocks or shortcode. We will explore both options below.

Using Gutenberg to Add a Menu

If you are using the Gutenberg block editor, you can add the menu to your pages and posts as follows:

  • Open the page or entry where you want to add the menu.
  • Click on the button + to add a new block.
  • Look for the block called Menu and select it.
  • Choose the menu you want to display from the drop-down menu.

Incorporating a Menu by Short Code

If you prefer to use a short code to insert the menu, you can do it as follows:

[wp_nav_menu name="menu-name"]

Be sure to replace menu-name by the actual name of your menu. This method is useful if you want to insert the menu in a specific place that is not available through the blocks.

Navigation Menu Customization

Customizing your navigation menu not only makes it more visually appealing, but also improves the user experience. Below, we will explore some customization options.

Menu CSS Styles

To customize your menu, you can add custom CSS styles. Here is a basic example:

.menu {
    background-color: #333;
    color: white;
}

.menu a {
    color: white;
    padding: 10px;
    text-decoration: none;
}

.menu a:hover {
    background-color: #555;
}

This code will change the background of your menu to a dark color and improve the visibility of the links when hovering over them.

Responsive Menus

It is crucial that your menu is responsive to adapt to mobile devices. Make sure your theme is optimized for this or consider using a plugin that makes it easy to create responsive menus.

Plugins to Enhance Navigation Menus

There are several plugins that can help you create more advanced navigation menus. Some of the most popular ones are:

  • Max Mega MenuDrop-down menus and mega menus can be created in a simple way.
  • WP Mobile MenuIdeal for improving the usability of the menu on mobile devices.
  • UberMenuA premium plugin that offers great flexibility and customization.

By implementing these strategies, you will be able to create an effective and attractive navigation menu on your WordPress site, thus improving your users' experience and the functionality of your website.