Wordpress Themes
Wordpress 1.3 includes a “Presentation” section in the admin area; its use is to switch between themes that have been installed. But there’s currently little to no documentation about what themes actually are, and how they’re written, how they’re installed, and how they work.
I seem to have figured it all out. At least, I think I have. There’s still some robustness checking I should do, in case specific files in my theme aren’t present, but here are the steps I took to make what you see here into a wordpress theme.
- First and foremost, create the style.css for your theme. You will need to make specific additions to the top of the stylesheet page, specifically the following portion:
/* Name: URI: Description: Author: Author URI: Template: Version: */
Fill all of those fields out. For “Template”, put the name of the directory you’ll be installing your theme in. In my case, “Template” is “devlogic-condition”. This will enable wp-blog-header.php and other files to actually locate your theme files and use your custom index, header, footer, and sidebar files. - Now, make a directory to hold the actual pages you use to display your site. This includes index.php, wp-comments*.php, wp-header.php, wp-footer.php, and wp-sidebar.php (if you’re basing your theme off of the new “modular” page layout). Copy all of the files you modified (or plan on modifying) to a new directory, and then make a few small changes. In your theme’s index.php file, you should ignore the warning at the top and delete the line “require(’./wp-blog-header.php’);”. It’s already called by the master index.php file in the webroot, and I’m pretty sure that calling it a second time does nothing more than increase the page load time.
Then, modify all of the php files you just copied, thusly:
find all of the lines that use the include() function, and modify the arguments. Change
include(ABSPATH . '/filename.php');
toinclude(ABSPATH . "wp-content/${wp_template}filename.php");
This makes the modular system load your custom header, footer, and sidebar files. It took me a while to figure that out, let me tell you. - copy and/or move the directory everything’s in into your wp-content/themes/ directory, and make sure the dir’s name is the same as the value you entered for “template” in step 1.
- Oh, yeah. Once everything’s in place, go to the “Presentation” menu in wp-admin, and enable your theme. If everything worked correctly, you should be able to view your site with your theme instead of whatever was there before. The most dramatic way to see this actually work is to put your theme file into a fresh installation of wordpress 1.3cvs (or release, when it comes out); you will see everything with the nice “default” theme (or “Kubrick”, if it’s there), before enabling your own hard work (or your hacking of someone else’s hard work, whatever).