How To Link Logo To Homepage of Your WordPress Website?
October 3rd, 2016 | by Ravi Chahar || 2 Comments |
After adding the custom header image on your website, you should link logo to homepage so that when your readers click on that logo, they reach to the homepage of your website.
When you develop a WordPress theme then these type of small things are crucial to look upon. The WordPress theme file structure consists many files.
As you know the logo is shown in the header area, so edit the header.php file. But how would you link logo to homepage?
In this tutorial, I will guide you to take the required action.
Edit header.php File To Link Logo To Homepage of Your Site?
You may know that for editing the theme files, you have to go to appearance>>editor>>header.php. First of all, you should know the type of code which shows the custom header.
As you all know that for making a link, we use HTML link tag. The situation is same. You just have to do it properly. There would be PHP codes including the WordPress functions.
Let me show you an example.
This code will help you to show the header image image you add from the WordPress theme customizer.
You can see there is no HTML link tag. You have to link logo to homepage by using another WordPress function.
Embed the above-mentioned code in the link tag and target it to the homepage of your WordPress website.
Let me provide you the final code.
This code will create a link to the logo of your website and take your readers to the homepage. You may have noticed that the “alt” tag of the header image is “yourwebsite“. You can change it according to you.
The extra code is the link tag and the target WordPress function.
<?php echo home_url(); ?>
You can give any HTML ID or class to the header image. It would help you to adjust it.
Isn’t That So Easy To Link logo To Homepage?
For a WordPress website, ever single part matters a lot. Whether you develop your own theme or you edit the pre-developed theme, you must know how to link a logo to homepage.
I have provided the best and easy code. You have to understand the concept of link building using HTML and the WordPress functions.
If you still crave to know more, feel free to ask.