This is the title of Joost de Valk post, which I don’t agree completely, some points are too stiff and should be considered and well thought through by the author ahead of the actual coding.
I made some thoughts and wrote down how I would start programming a perfect theme. Please don’t hesitate to comment and put in your thoughts on this article, which enhance the value of this post.
Checklist; check your work
- Thought about template files?
- style.css including comments?
- Added hooks?
- Search necessary, if so – does it exist?
- Widgetized?
- Plugin integration?
- Readable & valid code?
- Tested in different browser?
- Trackbacks?
- Title?
Background & Information to the checklist
-
Which template files in theme?
WordPress supports a lot templates in a theme and additionally you can add more functionality to it.
Especially because you can use WordPress for many different purposes, it’s essential to think about the necessary templates in advance. Really mandatory is onlyindex.php
. But I would recommend use at least:index.php
header.php
footer.php
– if you have a footer area.sidebar.php
– only if you have an extra area for a sidebar.single.php
– should there be an alternative style compare to the home page, it is advisable to have this template.page.php
– if there will exist static pages and look different toindex.php
.
-
Stylesheet incl. comment assignment?
WordPress needs a
style.css
. Without this file, including following comments, WordPress won’t be able to recognize the theme and cannot use it.
This file can also refer to other stylesheet files.@charset 'UTF-8'; /* Theme Name: Basis Theme URI: http://bueltge.de/basis-theme-fuer-wordpress/411/ Description: Basis style to start a new theme Version: 0.1 Author: Frank Bueltge Author URI: http://bueltge.de/ */ @import url(css/style.css);
-
Hooks in your theme?
Many Plugins and WordPress too is using the hooks in a theme. There is a minimum of 3 hooks in a theme
- In the
header.php
orindex.php
, depends on the structure of the theme:wp_head();
. This hook has to be in the header, preferable directly above the closing head tag. - Also should be a hook in the footer area of the website. Implement
footer.php
orindex.php
, if afooter.php
doesn’t exist.
Depends on what is implemented in a hook, I would recommend to have the hook inside the layout. This is just a recommendation, but it can’t be generalized.
- In the