- WordPress 2.7 Cookbook
- Jean-Baptiste Jung
- 509字
- 2021-04-01 13:55:49
Integrating your own logo
By default, most WordPress themes display a header text—usually the name of the blog and blog description. This is a nice option for personal blogs. However, I personally believe that displaying your own personal logo will make your blog look even more professional.
In this recipe, we shall learn how we can add a logo instead of the default blog name and slogan on a WordPress theme. The following screenshot shows the logo integration on a default WordPress theme:

Getting ready
For this recipe, you'll need your own logo and a WordPress theme on which you'd like to integrate your logo. I shall be using the WordPress default theme for this recipe.
However, there are a few things to be kept in mind before getting on with this recipe:
- Some recent themes don't display blog name and slogan anymore—instead, they display a default logo which can be changed by editing the code or even by defining a new logo in a custom WordPress control panel (which shall be covered in Chapter 3).
- Due to the fact that each theme is coded differently, the result of this recipe may vary from one theme to another.
How to do it...
- Open the
header.php
file and locate the part of code where the blog name and description are displayed. In the WordPress default theme, it looks like this:<div id="header"> <div id="headerimg"> <h1><a href="<?php echo get_option('home'); ?>/"><?php bloginfo('name'); ?></a></h1> <div class="description"><?php bloginfo('description'); ?></div> </div> </div>
- We can just put an
html
image tag between the<h1>
and</h1>
tags, but there's a much better, SEO friendly, way to display our logo—by using CSS. - Upload your logo into your
wp-content/themes/default
folder. Once you're done, open thestyle.css
file from the WordPress default theme. Go to line number 95. You'll see the CSS properties for the#headerimg .description
element:#headerimg .description { font-size: 1.2em; text-align: center; }
- Now, replace the preceding piece of code by the following piece of code:
- Don't forget to change the image name and path if your logo isn't named
logo.png
or is not located atwp-content/themes/default/images
.
How it works...
As you have seen, we haven't edited a single line of HTML to achieve our logo integration. We didn't have to, and it's better this way. Having h1
, an html element, as the header text is good for your semantic and SEO. Due to the text-indent
CSS property, we're able to hide the text by indenting it—this is the reason why we added this property to both #headerimg h1
and #headerimg .description
.
We do not want our logo to be hidden, this is why we used the CSS background property to display it.
There's more...
Our logo looks good, but its usability can be improved even more by adding a link to the logo on the blog homepage.
- Moodle 1.9 for Teaching 7/14 Year Olds: Beginner's Guide
- Sphinx Search Beginner's Guide
- Yii 1.1 Application Development Cookbook
- Creo 6.0快速入門、進階與精通(升級版)
- 視覺封王:Photoshop CC 2019立體化教程(素材+視頻+教案)
- 人臉識別算法與案例分析
- Joomla! Social Networking with JomSocial
- Illustrator 2024從入門到精通
- NHibernate 3.0 Cookbook
- Microsoft Dynamics GP 2010 Reporting
- Photoshop CS6從入門到精通
- Spark Cookbook 中文版
- Instant Flask Web Development
- AI繪畫+LoRA模型訓練從新手到高手
- Premiere Pro基礎與實戰教程