My home page is a dynamic page and on my navbar I have different static pages I want to add one to link to the homepage as if I clicked the logo.
2 Answers
To add a link to the homepage in your navbar, you can use the following function to add a link to the home page in wp_page_menu_args
function wpse01_home_link( $args ) {
if ( 'main-menu' === $args -> theme_location){
if (! isset( $args['show_home'] ) )
$args['show_home'] = _x( 'Home', 'homepage' );
}
return $args;
}
add_filter( 'wp_page_menu_args', 'wpse01_home_link' );
You can just rename Home
to suite your needs
-
It works just fine but it adds the link on a separated menu what ruins the navbar– yes_inCommented Jun 9, 2014 at 8:23
-
Check update, add condition to only add home to primary menu Commented Jun 9, 2014 at 8:32
-
-
No, not really! sorry what do you mean by check update ? update the page under the pages menu or what ?– yes_inCommented Jun 9, 2014 at 11:04
-
I have updated/changed the code in my answer, that is what I meant :) see if that helps Commented Jun 9, 2014 at 11:10
You can add "Custom" links to WordPress menus. There, just enter the URL to your website with the title you want.
-
-
That's good to hear. If the answer works for you, please mark it as "Accepted".– engelenCommented Jun 9, 2014 at 11:11