Theme Development Essentials
July 14, 2012
Instructor: Joe Querin (@joequerin)
What is a theme?
A collection of PHP scripts, CSS files, and images to create the look and feel
Can also include:
- Custom post types
- Theme options
- Nav menus
See http://codex.wordpress.org/Template_Hierarchy for more
Important to define theme name and description.
/* Theme Name: Twenty Ten Theme URI: http://wordpress.org/ Description: The 2010 default theme for WordPress. Author: wordpressdotorg Author URI: http://wordpress.org/ Version: 1.0 Tags: black, blue, white, two-columns, fixed-width, custom-header, custom-background, threaded-comments, sticky-post, translation-ready, microformats, rtl-language-support, editor-style, custom-menu (optional) License: License URI: General comments (optional). */
Allows you to develop child themes that inherit look, feel, and functionality from the parent theme.
Popular theme frameworks
Making a theme responsible
Child themes should allow the user to customize the look of the site without impacting underlying functionality. This means that the parent theme can be updated and pass on its updates to child themes.
Why create a custom theme?
- Functionality is required that cannot be accomplished through plugins
- Unable to find a theme that can either be modified or have a child theme created for it
- Because you want to!
Where to start
- WordPress Codex
- Look at a sample theme (TwentyTen, TwentyEleven)
- Download a theme from the wordpress.org repository
What not to do
Download a theme from a "free wordpress theme" web search
Questions to ask when you get started
- Are you going to create a framework/use a framework to start?
- Will the theme be a child theme based on someone else's theme?
- How will the site function?
- Mostly posts, pages, or a mix?
- Create a design for your theme
- Decide how to divide your theme so you can crete the necessary files
- Go to the codex
WPDEBUGin wp-config.php to catch deprecated code
- Try to break your theme
- Theme Check Plugin
- If you try to change the WordPress core files, you're gonna have a bad time
- Consider putting Google Analytics directly into your theme, which cuts down on your plugin overhead
- Evaluate current plugins and see what you can get away with not using
- If you're missing the admin bar, make sure you have
<?php wp_footer(); ?>
- Setup a good development environment