Adding a logo to the header generated by WordPress Default theme
When I started this blog, I did add categories ‘Computers‘ and ‘Programming‘. However, I made one decision: I will not cover HowTos on WordPress as part of this blog. The reason? There are at least two blogs for each WordPress related topic on earth. Yes, I know about giving back to the community (WordPress is free after all), but there are better ways in my opinion. The second reason was, have you ever noted someone talking on the Microphone about how to use the Mike? No, most people talk about other things, not about the Mike itself. Similarly, WordPress is a medium. A lot of the WordPress related blog posts are pilfered from elsewhere, even at times from WordPress.org 🙂
Yet, this is my first (and hopefully the only) WordPress HowTo. The reason is simple: I have come to realise that people come to blogs less to hear what is being said, and more learn how to speak their own thing. 🙂 So, being human, and wanting to hike my readership I have joined the bandwagon. At least this isn’t pilfered from anywhere.
Doing this is quite easy. Go to the folder /wp-content/themes/default/images
under your WordPress folder. In this folder, locate the file called header-img.php
. You should see a line of code written like this:
//die;
header("Content-Type: image/jpeg");
Add two lines of code above this, making it look as below:
$hsim = imagecreatefrompng('logo.png');
imagecopy($im, $hsim, 70, 50, 0, 0, 100, 100);
//die;
header("Content-Type: image/jpeg");
imagejpeg($im, '', 92);
Here, logo.png is your logo image which is also lying the same folder. The numbers 70, 50 are the coordinates of upper left corner where you want your logo to appear – experiment a bit to find out what looks best for your logo. The numbers 100,100 are the width and height respectively of your logo image.
Have a look at how the result appears for me:
Thats it! Easy – just try it and post any questions/queries/suggestions.