How to show Home Page link in WordPress Menu and how to add an icon to this?

I tried with this code:

function home_page_menu_args( $args ) {
$args['show_home'] = true;
return $args;
}
add_filter( 'wp_page_menu_args', 'home_page_menu_args' );

but gives me this error: Error 404 - Not Found

Read More

I would like that when I click on “Home Page” menu appears the recent posts.
And I would like to place an icon instead of “Home Page” writing.

Thank you!

Related posts

Leave a Reply

2 comments

  1. To add a home link to menus that you create via the menus admin area:

    1. go to the Pages box,
    2. click the ‘View All’ tab
    3. ‘Home’ will appear, check the box and click ‘add to menu’

    enter image description here

  2. If you programmatically want to add the HOME menu item in the main menu (primary) then you can do with the following code.

    add_filter( 'wp_nav_menu_items', 'maple_custom_menu_filter', 10, 2 );
    function maple_custom_menu_filter( $items, $args ) {
        /**
         * If menu primary menu is set.
         */
        if ( $args->theme_location == 'primary' ) {        
    
            $home = '<li class="menu-item"><a href="' . esc_url( get_home_url( '/' ) ) . '" title="'.esc_attr( get_bloginfo( 'name', 'display' ) ).'">Home</a></li>';
            $items = $home . $items;
        }
    
        return $items;
    }