Do not keep your blog theme to the minimum


While you can get by with just style.css and index.php in your theme, it is generally not such a good idea to be so minimalist. At the very least, you should also have a header.php and a footer.php for your theme.

These are called from within index.php, with the template tags get_header() and get_footer(). You’ll also want a comments.php for commenting functionality, and you call that with get_comments(), also from within index.php. The same goes for the sidebar; you should have a template file for that too, and call it with get_sidebar().

The header.php file consists of the doctype heading and everything related. We’ll take a closer look at that in the following example section. Other things the header.php file generally does are basic stufflike getting the right favicon, generating proper title tags, and having the necessary keywords so that search engines can find the pages more easily.

However, one thing it must have is a link to the stylesheet, and the wp_head() is also needed to start the whole WordPress shebang.

Moving on, footer.php should include wp_footer() to stop WordPress and, of course, all the necessary closing tags. You want to close the body and html tags, and anything else you may have opened in header.php.

Finally, comments.php needs the code for outputting comments, as well as the necessary forms so that people can actually post new comments. This is done with simple template tags these days, so comments.php files aren’t as messy to work with as they once were, or at least appeared to be. The simplest file of them all is sidebar.php, which is just the stuffyou want in the sidebar.

As you may have gathered, everything revolves around index.php. However, there are other template files that can replace index.php, depending on the situation.

If you’re on the front page, for example, home.php takes the top slot, and index.php will only be used if there isn’t a home.php. The same goes for single post view, where single.php takes precedence above index.php, and for WordPress pages page.php goes before index.php. Actually, if you utilize every one of the possible template files, your index.php file will never load. The concept is the same, though, so leave things like that for a little while.

This is how it works. At the top, spanning the full width, is the weblog header, which in fact is the header.php file. Underneath is the actual weblog area, with the content to the left(index. php) and the sidebar to the right (sidebar.php). Finally, there is a footer to wrap it up, using the footer.php template file.

This setup is not mandatory; you can change it, exclude parts of it, or expand it further. It is, however, a very common setup, one that the default WordPress theme as well as the Notes Blog Core theme adheres to. You’ll see a lot of themes using template files in this manner if you look around, but it is in no way the only way to do things. It is just common, that’s all.

Legal Disclaimer

Our website is not responsible for the information contained by this article. Webworldarticles.com is a free articles resource thus practically any visitor can submit an article. However if you notice any copyrighted material, please contact us and we will remove the article(s) in discussion right away.


This article was sent to us by: Gary Drumer at 05172010

Related Articles

1. Are you using WordPress as a CMS
WordPress as a CMS Using WordPress for things other than blogging is something that comes naturally to a lot of developers today, but not so much for the ge...

2. Things to Consider When Using WordPress as a CMS
Things to Consider When Using WordPress as a CMS So you’re considering using WordPress as a CMS for a project huh? Great, and probably a good choice too...

3. Trimming WordPress to the Essentials
Trimming WordPress to the Essentials Usually, when doing work for clients or other people within your organization, you’ll have to think a little bit diff...

4. Wordpress Static Pages and News Content
Static Pages and News Content I touched upon static Pages and categories as a news model previously. It is truly a great tool whenever you need to roll out a ty...

5. Making Widgets a Little More Dynamic
Putting Widgets to Good Use Widgets and widget areas are your friends when rolling out WordPress as a CMS. It is perhaps not as important for the small and stat...

6. Wordpress The Header and Footer Templates
The Job Board The first special project we’ll work on is a job board. You have probably seen this kind of site already, where people and companies can pos...

7. When using TDO Mini Forms to build this solution
Receiving the Jobs There are numerous ways to receive the actual content for the job listings. The easiest way would be to just have people e-mail listings to y...