Skip to content

Everything for WordPress, web development — and beyond

🔗 How to add a home link to the WordPress menu

🔗 How to add a home link to the WordPress menu

A navigation menu without a link to the homepage is like a front door without a handle. A visitor lands on an internal page through search, reads the content... and has no idea where to click to reach the homepage. The logo in the header does not always help; some users instinctively look for a "Home" item right in the menu.

Before version 3.0, WordPress had no such option in the standard menu editor, so you had to either edit the code or add a custom link manually. Now everything is simpler: a couple of clicks and the home link is in place. And if you are a developer or customizing a theme, there is the wp_nav_menu_items filter that solves the task with a single function.

Below you will find both methods: a visual one for regular users and a programmatic one for those who work with code. Plus we will cover when the link needs updating and what to do if it suddenly disappears.

💡 Quick overview:

  • Add a home link to the WordPress menu via the admin panel in under a minute without plugins.
  • Add the link programmatically using the wp_nav_menu_items filter in the theme's functions.php.
  • Verify and update the URL after changing domains or switching to HTTPS.

Method 1: via the WordPress admin panel

This method works with WordPress 3.0 and later, meaning on any modern site. No plugins or code edits are required.

Log in to the admin panel and navigate to Appearance → Menus. On the left you will see blocks: "Pages," "Posts," "Custom Links," and others depending on installed plugins and content types.

In the Pages block, click the All tab (or "View All" in older versions). The very first entry is a page named "Home." Check its box and click Add to Menu.

Pages block in the WordPress menu editor with the Home item

Once added, the item will appear in the menu structure on the right. Drag it to the desired position; it is usually placed first or last. Save the menu by clicking Save Menu, and the home link will go live on your site.

By default, WordPress uses the direct URL of the homepage for this item (for example, https://vash-sait.ru/). This is important to remember: if you later move the site to a different domain or switch from HTTP to HTTPS, the link will retain the old address. You will have to open the menu editor and fix the URL manually, or delete the item and re-add it (WordPress will insert the current address automatically).

Method 2: programmatic addition via a filter

If you are developing a custom theme or want the home link to be added automatically when the theme is activated, use the wp_nav_menu_items filter. It intercepts the HTML of menu items before output and lets you insert your own element.

Place the code in the functions.php of the active theme (or a child theme so you do not lose changes on update). An alternative is the Code Snippets plugin: you create a snippet, paste the code, and activate it; the changes are then independent of the theme.

Code Snippets plugin page in WordPress
1/**
2 * Adds a "Home" link to the main WordPress menu.
3 *
4 * @param string $items HTML markup of menu items.
5 * @param object $args wp_nav_menu() arguments.
6 * @return string
7 */
8function sdstudio_add_menu_home_link( $items, $args ) {
9 // Target menu location — replace 'main' with your own value
10 if ( 'main' !== $args->theme_location ) {
11 return $items;
12 }
13
14 $home_link = sprintf(
15 '<li class="menu-item"><a href="%s">%s</a></li>',
16 esc_url( home_url( '/' ) ),
17 esc_html__( 'Home', 'textdomain' )
18 );
19
20 // The link is added first — put $items . $home_link if you need it last
21 $items = $home_link . $items;
22
23 return $items;
24}
25add_filter( 'wp_nav_menu_items', 'sdstudio_add_menu_home_link', 10, 2 );

The key parameter is 'main' in the if condition. This is the slug of the menu area (theme location) registered by the register_nav_menu() function in the theme. You can find your slug in the theme's functions.php: look for the call to register_nav_menu() or register_nav_menus() and check the first argument. Most often it is primary or main.

The function is safe: esc_url() escapes the URL, and esc_html__() escapes the link text while supporting translation. If you use a child theme, replace 'textdomain' with your theme's text domain.

After inserting the code, refresh the site and the home link will appear in the menu automatically. You do not need to remove it manually: simply comment out or delete the add_filter() call and everything will revert to the original state.

A home link added via the admin panel stores a hard-coded URL, the one that was in the site settings at the time of addition. Three common scenarios when it breaks:

  • Switching from HTTP to HTTPS. The menu item continues pointing to http://..., browsers may display a mixed-content warning, or the redirect may fail. Solution: open the menu editor, delete the old "Home" item, and add it again; WordPress will insert the current https:// URL.

  • Changing the domain. When moving a site from a dev environment to production (staging.site.rusite.ru) or migrating to a completely new domain. The menu item keeps the old URL. Solution: same as above (delete and re-add).

  • Moving from a subdirectory to the root. If the site relocates from site.ru/blog/ to site.ru/, all hard-coded links break. After migration, go through ALL menu items, not just the home link.

The programmatic method (via wp_nav_menu_items) does not have these problems: home_url('/') always returns the current homepage address from WordPress settings.

By the way, if you work with menus frequently, check the navigation settings under Appearance → Customize, where you can manage menus in real time with a live preview. For advanced edits (adding icons to items, mega-menus) there are dedicated tools, but that is a topic for another article.

Video: adding a home button in 2 minutes

If you prefer watching to reading, here is a short English-language video with a step-by-step screen demonstration:

⁉️🤔 Frequently asked questions

Can I add a home link without plugins or code?

Yes, through the standard WordPress menu editor: Appearance → Menus → Pages block → check "Home" → Add to Menu. This is core functionality available since version 3.0.

Why did the home link disappear from the menu after changing themes?

Menus in WordPress are tied to menu areas (theme locations) registered by the theme. When you switch themes, the old areas disappear and the new ones may have different names. Your menu has not gone anywhere; it simply became "unassigned." Go to Appearance → Menus → Manage Locations tab and assign the existing menu to an area of the new theme. All items, including the home link, will return.

The menu already has a "Home" item, but it leads to some specific page rather than the site root. How do I fix this?

Most likely a specific page titled "Home" was added to the menu instead of the special "Front Page" type. Remove that item from the menu, then in the Pages block find the entry labeled "Front Page" (WordPress marks it distinctly) and add it. If there is no such label, use "Custom Links": in the URL field enter /, and in the "Link Text" field type "Home."

How do I add the home link last in the menu instead of first?

In the programmatic method, swap the concatenation order: instead of $home_link . $items write $items . $home_link. In the visual editor, simply drag the "Home" item to the end of the list and save the menu.

Is it necessary to use esc_url() and home_url() in the code?

Yes, this is WordPress best practice. home_url('/') dynamically inserts the current site address from settings, so you will not need to edit the code when changing domains. esc_url() escapes special characters and protects against XSS attacks. Skipping escaping in production code is risky.

Does the code method work on a WordPress multisite installation?

Yes, home_url( '/' ) on multisite returns the URL of the specific site within the network (the one specified in that sub-site's settings). Each site in the network will have its own home link. If you need different behavior for different sites, wrap the add_filter() call in a condition that checks the blog ID via get_current_blog_id().

First, check the obvious: did you actually save the menu after adding the item? The "Save Menu" button is at the bottom of the page; without clicking it the changes are not applied. If the menu is saved but the item is missing, open the site in incognito mode (the browser cache sometimes hides recent changes).

The second likely cause is a caching plugin (WP Rocket, W3 Total Cache, LiteSpeed Cache). Clear the cache via the plugin's admin panel and recheck the site.

If that does not help, temporarily switch the theme to a default one (Twenty Twenty-Five or Twenty Twenty-Six). Did the item appear? Then the problem is in the custom theme; its wp_nav_menu() function may be overridden with filters stripped out. Check the wp_nav_menu() call in the theme template: the 'items_wrap' argument should not be an empty string, and 'fallback_cb' should be false only if you intentionally disable the fallback.

The code from "Method 2" works on any theme as long as the theme_location is correct; it serves as insurance in case the visual method fails for some reason.

A home link in the menu is a small detail that builds trust. A visitor who lands on an internal page from search finds the path back to the start in a split second and continues exploring. Without it, part of your audience will simply close the tab. Two minutes in the menu editor or ten lines of code, and this entry point is never lost again.