Client Friendly WordPress Themes: Header.php
So today I wanted to take some time to talk about how you can make a WordPress theme more friendly for your clients, friends and general distribution by taking advantage of the template system built in to WordPress.
We are going to start with the header, an often misunderstood part of the WordPress theme. The part of the theme that can do a fair bit of the heavy lifting in a theme.
Here is the full text of the code I am going to dissect for you today:
” rel=”stylesheet” type=”text/css” />
The first thing that is relevant to WordPress theme authors is the title tag. Most people, by default just put the name of their blog, and a catch phrase as their title and while this is all well and good, for search engine optimization purposes, you might want to go another route. Sure, there are WordPress plugins that can help you add more optimizations to your blog, but I don’t like to have to rely on plugins, unless I have to, especially when I am going to be giving a theme to someone else.
What I have done here is to basically say, “if we are on the home page, show the blog’s name, and description, otherwise show the title of the current article and then the title of the blog.” While this is not perfect, it is a huge step up from just showing the blog’s name, and description on every page, and every article.
The bloginfo(‘name’) and bloginfo(‘description’) come from the WordPress administration under, the Options -> General panel in the sections that say, Blog Title and Tag line.
The next line of note includes another reference to bloginfo, but this time asking for the template URL.
The next relevant line is dealing with the stylesheet. WordPress looks for style.css when using their templating code, so make sure your style sheet is appropriately named.
To reference it, just use the following code:
If you want your theme to work with plugins that exist, then adding in the wp_head call is very important. This little function allows a vast number of WordPress plugins to add all sorts of code to the top of the theme. I have seen far too many of them not include it, and thus a huge number of users complained.
WordPress Codex, you too can start to make your WordPress theme work well, no matter who uploads it.
Idea for this post by Chris Garrett of the449.