
Let’s build WordPress theme – part 2
All right now, as you may remember in previous part we have already built WordPress theme but at this point, it is completely terrible and useless. However, we can see posts and this is it. Today we will do a little more. Let’s start.
HTML Declaration
We will use HTML5, so we leave Doc Type declaration as it is. But we have to take care about browsers (especially older versions of Internet Explorer) and we need to set proper language attribute. Because we do not know which WordPress language version will be used by the user, we need to use language_attributes() function. Then we have to use some conditional comments in HTML, to make sure that proper class will be used to HTML declaration, depending on what IE version is in use. This may look like this:
1 2 3 4 5 6 7 8 9 |
<!--[if IE 7]> <html class="ie ie7" <?php language_attributes(); ?>> <![endif]--> <!--[if IE 8]> <html class="ie ie8" <?php language_attributes(); ?>> <![endif]--> <!--[if !(IE 7) & !(IE 8)]><!--> <html <?php language_attributes(); ?>> <!--<![endif]--> |
Head Section
Char set declaration
First of all, char set declaration. In most cases this is simply UTF-8, but what will happen if we are wrong? No special characters, only garbage on the screen. We want to avoid that, for sure. Let’s declare char set using WordPress settings:
1 |
<meta charset="<?php bloginfo( 'charset' ); ?>"> |
View port and initial scale
We won’t touch it at this point, because WordPress itself didn’t gave us anything to set here.
Ping back url
We can add ping back (or track back) url to our site. It may improve WordPress position at search engines results page, it may not. It is all up to you, we will add it here:
1 |
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>"> |
Learn more about ping / track backs at WordPress Codex page.
Body declaration
In body declaration we have to print classes, because some of the plug-ins and WordPress itself may add specific classes. It is pretty simple, it looks like this:
1 |
<body <?php body_class();?>> |
And this is it. The rest of the files won’t be changed, except maybe style.css – we will change version mark to 0.1.2. Those all changes won’t modify the way our theme looks. But it is a big step to integrate our code with WordPress. Here you can download booyah-0.1.2.

