Menu Close

How to a Add Homepage Link To your WordPress Menu


Most WordPress sites will likely have a link in the primary menu that goes to the homepage so visitors can easily navigate your site. Luckily it is very easy to add your home link in WordPress since version 3.0. To add your home link simply log into your WordPress dashboard and go to Appearance > Menus and under the “pages” section on the left side click on the “View All’ option and the very first option should be your home link which you can add to the menu.

See the screenshot below:

When you add the Home Link to your menu it will use a direct URL to your website’s homepage. So if you ever migrate your site or switch from http to https you need to make sure to update the menu item accordingly.

Adding a Home Link via Code

Now if you want to get a bit fancy or if you are working on a custom WordPress theme you can easily add your home link to your main menu using code by hooking into the wp_nav_menu_items wordpress filter. See the example snippet below.

 * Add a home link to your menu
 * @since 4.0
function wpex_add_menu_home_link( $items, $args ) {

	// Only used for the main menu
	if ( 'main' != $args->theme_location ) {
		return $items;

	// Create home link
	$home_link = '<li><a href="' . esc_url( home_url( '/' ) ) . '">Home</a></li>';

	// Add home link to the menu items
	$items = $home_link . $items;

	// Return menu items
	return $items;
add_filter( 'wp_nav_menu_items', 'wpex_add_menu_home_link', 10, 2 );

Simple change where it says “main” to be the name of the menu location where you want the home link to be added.

View Source
Posted in WordPress