I have a menu linking to each of my pages, but I cannot seem to get the link to my front-page working...What is the correct way in Wordpress to link back to your front-page? This works for all of the other pages, just not for my front-page:

<a href="<?php echo get_page_link( get_page_by_title( 'Home Page' )->ID ); ?>"> Home. </a>

My front-page template does have the "Home Page" name so I'm not sure why this works with all of the other pages but not this one.


You can use home_url(), which will point to the Site URL regardless of reading settings and/or what page it is:

echo esc_url( home_url( '/' ) );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.