J2 – It’s the New Black

"Geranium" by Jacques Heim (1958)

“Geranium” by Jacques Heim (1958) by jinterwas, on Flickr

Being determined to bring my WordPress project back on track, I downloaded Jesse’s J2 theme from his website. I started the WAMP server, closed every other window on The Geriatric Laptop, said a little prayer, and started WordPress.

It only took about three whiny time-outs, but I got it up and activated the J2 theme. It didn’t look as pretty as in the book. Click on the image to see aΒ  larger one.

J2

Jesse’s Static Theme

It’s all static HTML, and our mission, should we choose to accept it, is to rewrite it using dynamic PHP calls instead, just like we did with that little First Theme. Once we’ve done that, a user can change all sorts of things from the WordPress settings instead of having to recode the file, and life will be so much better.

Header Stuff

The first chapter of this section deals with the header file. This file is important because it tells WordPress all sorts of things it needs to know about our theme. Click on the picture to see it larger, and refer to it if you are wondering where the lines below come from. They are right at the top of the file.

Jesse's Header File

Jesse’s Header File

 

<html>

For example, the file we received tells WordPress that our document is written in HTML5 – that isn’t going to change. We leave our document type declaration as:

<!DOCTYPE html>

But the language our users are working in may well differ from ours. So rather than hard-coding US English and having to change it if we decide to work in French instead, we use:

<html <?php language_attributes(); ?>>

If we set our language in the settings to US English, this code will result in:

<html dir=”ltr” lang=”en-US”>

just like in the static HTML file.

<title>

Next Jesse tackles the page title. In Chapter 4 we used a simple function to grab the information from the settings, but now we are getting fancy. We have to write things in such a way that somebody else’s plugin can change our whole title, probably for the purposes of Search Engine Optimisation, the Holy Grail of the online life.

The way we do this is through something called a filter, which, if I understand it correctly, intercepts the information in the settings before it makes it into the Β HTML (which will then put it on the screen for our readers, and Google, to admire). Jesse goes on to demonstrate how to implement a filter, but first I need to do some more thinking about it. Next post in this series will definitely be about filters!

Facebooktwitterlinkedinyoutubeinstagram

One thought on “J2 – It’s the New Black

  1. Mosi says:

    hi. thank you for your post.
    what’s happening for wdgwp.com ?
    i had ebook, but i hadn’t any soure code. can you email me?
    Thanks
    Mosi

Leave a Reply

Your email address will not be published. Required fields are marked *

CommentLuv badge

This site uses Akismet to reduce spam. Learn how your comment data is processed.