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.
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
1. Are you using WordPress as a CMS
All articles in this directory are property of their respective authors. Additionally, read our Privacy Policy
© 2010 WebWorldarticles.com - All Rights Reserved.