Welcome to WordPress theme design! This title is intended to take you through the ins and outs of creating sophisticated professional themes for the WordPress personal publishing platform. WordPress was originally, and is foremost, a blog system. Throughout the majority of this book's chaptersâfor simplicity's sakeâI'll be referring to it as a blog or blog system. But don't be fooled! Since its inception, WordPress has evolved way beyond mere blogging capabilities and has many standard features that are expandable with plugins and widgets, which make it comparable to a full CMS (Content Management System).
In these upcoming chapters, we'll walk through all the necessary steps required to aid, enhance, and speed your WordPress theme design process. From design tips and suggestions, to packaging up the final theme, we'll review the best practices for a range of topicsâdesigning a great theme, rapid theme development, coding markup, testing, debugging, and taking it live.
The last three chapters are dedicated to additional tips, tricks, and various "how to" recipes for adding popular site enhancements to your WordPress theme designs using third-party plugins, as well as creating your own custom plugins.
As you're interested in generating custom themes for WordPress, you'll be very happy to know (especially all you web standards evangelists) that WordPress really does separate content from design.
You may already know from painful experience that many content management and blog systems end up publishing their content pre-wrapped in (sometimes large) chunks of layout markup (sometimes using table markup), peppered with all sorts of predetermined selector
You usually have to do a fair amount of sleuthing to figure out what these
classes are so that you can create custom CSS rules for them. This is very time consuming.
The good news is, WordPress publishes only two things:
The site's textual contentâthe text you enter into the post and the page administration panels
Supplemental site content wrapped in list tagsâ
</li>âwhich usually links to the posts and pages you've entered and the meta information for those items
That's it! The list tags don't even have an ordered or unordered defining tag around them. WordPress leaves that up to you. You decide how everything published via WordPress is styled and displayed.
The culmination of all those styling and display decisions, along with special WordPress template tags that pull your site's content into you design, are what your WordPress theme consists of.
The answer to this question isâno. Even before the release of themes in WordPress 2.x, WordPress has been capable of managing static pages and subpages since version 1.5. Static pages are different from blog posts in that they aren't constrained by the chronology of posts. This means you can manage a wide variety of content with pages and their subpages.
WordPress also has a great community of developers supporting it with an ever-growing library of plugins. Using plugins, you can expand the capabilities of your server-installed WordPress site to include infinite possibilities such as event calendars, image galleries, sidebar widgets, and even shopping carts. For just about anything you can think of, you can probably find a WordPress plugin to help you out.
By considering how you want to manage content via WordPress, what kind of additional plugins you might employ, and how your theme displays all that content, you can easily create a site that is completely unique and original in concept as well as design.
Again, WordPress was built to be a blog system, and it has some great blog post and category tools. But if you want to use it to manage a brochure-style site, have a particular third-party plugin to be the main feature of your site, and downplay or even remove the blog, that's fine too! You'll just tweak your theme's template files to display your content the way you prefer (which is something you'll be very good at after reading this book).
I approach theme design from two angles.
Simplicity: Sometimes it suits the client and/or the site to go as bare-bones as possible. In that case, it's quick and easy to use a very basic, already built theme and modify it.
Unique and Beautiful: Occasionally, the site's theme needs to be created from scratch so that everything displayed caters to the specific kind of content the site offers. This ensures that the site is something eye-catching, which no one else will have. This is often the best route when custom branding is a priority or you just want to show off your "Hey, I'm hot-stuff" design skills.
There are many benefits to using or tweaking already built themes. First, you save a lot of time getting your site up with a nice theme design. Second, you don't need to know as much about CSS, XHTML, or PHP. This means that with a little web surfing, you can have your WordPress site up and running with a stylish look in no time at all.
The drawback to using an already built theme is that it may not save you as much time as you would hope for. You may realize, even with the new header text and graphic, several other sites may have downloaded and/or purchased it for themselves and you don't stand apart enough.
Perhaps your site needs a special third-party plugin for a specific type of content; it might not look quite right without a lot of tweaking. And while we're discussing tweaking, I find that every CSS designer is different and sets up their theme's template files and stylesheets accordingly. While it makes perfect sense to them, it can be confusing and time consuming to work through.
Your approach may have started out as simplicity, but then, for one reason or another, you find yourself having to dig deeper and deeper through the theme and pretty soon it doesn't feel like quick tweaking anymore. Sometimes you realizeâfor simplicity's sake (no pun intended)âit would have been a whole lot quicker to start from scratch.
Before trying to cut corners with a preexisting theme, make sure your project really is as simple as it claims to be. Once you find a theme, check that you are allowed to tweak and customize it (such as an open source or Creative Commons license or royalty free purchase from a template site), and that you have a look at the stylesheet and template files. Make sure the theme's assets seem logical and make sense to you.
Theme frameworks are wonderful in that they provide the core functionality of a theme, already started for you. The idea is they let you create child themes off the main theme, which you can then easily style to your liking.
They're particularly useful to designers who are short on time, very good with CSS, and don't want to deal with the learning curve of having to understand WordPress' template tags, hooks, and template page hierarchy.
The whole point of this book is to introduce you to the above concepts and introduce you to the basics of WordPress theme features so that you can create elegant comprehensive themes from scratch. You can then see how getting a little creative will enable you to develop any kind of site you can imagine with WordPress. You'll also be able to better take advantage of a theme framework, as you'll understand what the framework is accomplishing for you "under the hood" , and you would also be able to better customize the framework if you'd like to.
For many frameworks, there is still some amount of learning curve to getting up and running with them. But less of it will deal directly with futzing with PHP code to get WordPress to do what you want.
I'd encourage you to take a look at development with a framework and compare it to development from scratch. Having the skills this book provides you with under your belt will only help, even if you choose to go with a framework to save time.
Popular theme frameworks to choose from:
More and more frameworks show up every day, and each framework tries to address and handle slightly different focuses, features, and types of developers. As a bonus, some frameworks add options into the WordPress administration panel that allow the end user to add and remove features to/from the child theme they've selected.
You'll want to look at frameworks in terms of the options they offer that suit your development style, needs, and the overall community the framework caters to, to see if the framework is a good fit for your site's requirements.
WPFramework is a good general framework to start with (http://wpframework.com/). Its aim is to stay straightforward and simple, while cutting down theme development time.
If you're interested in a framework that offers a lot of child themes that can be easily tweaked with just CSS and will also add a lot of bells and whistles for the end user in the administration panel, you'll want to look at more robust frameworks such as Carrington (http://carringtontheme.com/), Thematic (http://themeshaper.com/thematic/), and Hybrid (http://themehybrid.com/).
These frameworks may appear a bit more complex at first, but offer a range of rich features for developing themes and, especially if you understand the essentials of creating WordPress themes (as you will after reading this book), can really aid you in speeding up your theme development.
Again, there are many theme frameworks available. A quick Google search for "WordPress Theme Frameworks" will turn up quite a plethora to choose from.
The approach of this book is going to take you through the unique and beautiful route (or unique and awesome, whatever your design aesthetics call for) with the idea that once you know how to create a theme from scratch, you'll be more apt at understanding what to look for in other WordPress themes. You'll then be able to assess when it really is better or easier to use an already built theme versus building up something of your own from scratch.
This book is geared toward visual designers (with no server-side scripting or programming experience) who are used to working with the common industry standard tools such as Photoshop and Dreamweaver or other popular graphic, HTML, and text editors.
Regardless of your web development skillset or level, you'll be walked through clear, step-by-step instructions. But there are many web development skills and WordPress know-how that you'll need to be familiar with to gain maximum benefit from this book.
Most importantly, you should already be familiar with the most current stable version of WordPress. You should understand how to add content to the WordPress blog system and how its posts, categories, static pages, and subpages work. Understanding the basics of installing and using plugins will also be helpful (though we will cover that to some extent in the later chapters of the book as well).
Even if you'll be working with a more technical WordPress administrator, you should have an overview of what the WordPress site that you're designing entails, and what (if any) additional plugins or widgets will be needed for the project. If your site does require additional plugins and widgets, you'll want to have them handy and/or installed in your WordPress development installation (or sandboxâa place to test and play without messing up a live site). This will ensure that your design will cover all the various types of content that the site intends to provide.
What version of WordPress 2.x does this book use? This book focuses on WordPress 2.7 and 2.8. Everything covered in this book has been tested and checked in WordPress 2.8.5. You may occasionally note screenshots from version 2.7 being used, but rest assured, any key differences between 2.8, 2.7, and even 2.5 are clearly noted when applicable. While this book's case study is developed using version 2.7 and 2.8, any newer version should have the same core capabilities, enabling you to develop themes for it using these techniques. Bug fixes and new features for each new version of WordPress are documented at http://WordPress.org.
If you are new to WordPress, then I recommend you read WordPress Complete by April Hodge Silver.
I'll be giving detailed explanations of the CSS rules and properties used in this book, and the "how and why" behind those decisions. You should know a bit about what CSS is, and the basics of setting up a cascading stylesheet and including it within an XHTML page. You'll find that the more comfortable you are with CSS markup and how to use it effectively with XHTML, the better will be your WordPress theme-creating experience.
You don't need to have every markup tag in the XHTML standard memorized. (If you really want, you can still switch to the Design view in your HTML editor to drop in those markup tags that you keep forgettingâI won't tell). However, the more XHTML basics you understand, the more comfortable you'll be working in the Code view of your HTML editor or with a plain text editor. The more you work directly with the markup, the quicker you'll be able to create well-built themes that are quick loading, semantic, expand easily to accommodate new features, and are search engine friendly.
You definitely don't have to be a PHP programmer to get through this book, but be aware that WordPress uses liberal doses of PHP to work its magic! A lot of this PHP code will be directly visible in your theme's various template files. PHP code is needed to make your theme work with your WordPress installation, as well as make individual template files work with your theme.
If you at least understand how basic PHP syntax is structured, you'll be much less likely to make mistakes while retyping or copying and pasting code snippets of PHP and WordPress template tags into your theme's template files. You'll be able to more easily recognize the difference between your template files, XHTML, and PHP snippets so that you don't accidentally delete or overwrite anything crucial.
If you get more comfortable with PHP, you'll have the ability to change out variables and call new functions or even create new functions on your own, again infinitely expanding the possibilities of your WordPress site.
Beef up those web skills!
I'm a big fan of the W3Schools site. If you'd like to build up your XHTML, CSS, and PHP understanding, you can use this site to walk you through everything from basic introductions to robust uses of top web languages and technologies. All the lessons are easy, comprehensive, and free at http://w3schools.com.
The more web technologies you have a general understanding of, the more likely you'll be able to intuitively make a more flexible theme that will be able to handle anything you may need to incorporate into your site in the future.
More of a visual "see it to do it" learner?
In order to get started in the next chapter, you'll need the following tools to help you out:
You'll need a good HTML editor. Dreamweaver is also a good option (http://www.adobe.com/products/dreamweaver/), although I prefer to use Coda for Mac (http://www.panic.com/coda/). When I was on a PC, I loved the free text/code editor HTML-kit (http://www.htmlkit.com/). Any HTML or text editor that lets you enable the following features will work just great. (I recommend you enable all of the following):
View line numbers: This comes in very handy during the validation and debugging process. It can help you find specific lines in a theme file, for which a validation tool has returned a fix. This is also helpful for other theme or plugin instructions given by the author, which refer to a specific line of code that needs editing.
View syntax colors: Any worthwhile HTML editor has this feature usually set as a default. The good editors let you choose your own colors. It displays code and other markup in a variety of colors, making it easier to distinguish various types of syntax. Many editors also help you identify broken XHTML markup, CSS styles, or PHP code.
View non-printing characters: You might not want this feature turned on all the time. It makes it possible to see hard returns, spaces, tabs, and other special characters that you may or may not want in your markup and code.
Text wrapping: This of course lets you wrap text within the window, so you won't have to scroll horizontally to edit a long line of code. It's best to learn what the key-command shortcut is for this feature in your editor, and/or set up a key-command shortcut for it. You'll find it easier to scroll through unwrapped, nicely-indented, markup and PHP code to quickly get a general overview or find your last stopping point; however, you will still want to turn it on quickly so that you can see and focus your attention on one long line of code.
Open source HTML editors: I've also used Nvu (http://www.net2.com/nvu/) and Kompozer (http://kompozer.net/). They're both free, open source, and available for Mac, PC, and Linux platforms. Kompozer was made from the same source as Nvu and, apparently, fixes some issues that Nvu has. (I haven't run into any major issue with Nvu myself; both editors are a bit limited for my regular use, but I do like being able to format XHTML text quickly and drag-and-drop form objects onto a page.) Both editors have a Source view, but you must be careful while switching between the Normal and the Source view tabs! Nvu and Kompozer are a little too helpful, and will try to rewrite your handcoded markup if you haven't set your preferences properly!
Linux users of Ubuntu and Debian (and Mac users with Fink) might also be interested in checking out Bluefish editor (http://bluefish.openoffice.nl). I haven't used it myself, but the site's writeup looks great.
The next piece of software you'll need is a graphic editor. While you can find plenty of CSS-only WordPress themes out there, chances are that you'll want to expand on your design a little more and add nice visual enhancements. These are best achieved by using a graphic editor such as GIMP, Photoshop, or Fireworks. Adobe owns both Photoshop and Fireworks and also offers a light and less-expensive version of Photoshop, called Photoshop Elements that will allow you to do everything I discuss in this book (http://www.adobe.com/products/).
While I'm an advocate of open source software and enjoy working with GIMP, in my line of work, the industry standard is Photoshop or Fireworks. I'll be using Adobe Photoshop in this title and assume that you have some familiarity with it or GIMP and working with layers. Any graphic editor you prefer is fine. One that allows you to work with layers is very helpful, especially with the design comping (or mockup) techniques I suggest in Chapter 2.
If you need a graphic editor, then you can try GIMP. If you're on a budget and in need of a good image editor, I'd recommend it. It's available for PC, Mac, and Linux. You can get it from http://gimp.org/.
On the other hand, if you prefer vector art, then try Inkscape, which is also available for PC, Mac, and Linux. Bitmap graphic editors are great in that they also let you enhance and edit photographs. But if you just want to create buttons or other interface elements and vector-based illustrations, Inkscape is worth trying out (http://inkscape.org).
Finally, you'll need a web browser. Here, I'm not so flexible. I strongly suggest that you use the latest stable version of the Firefox browser, available at http://mozilla.com/firefox/.
Now one may ask why use Firefox? I view this browser as a great tool for web developers. It's as essential as my HTML editor, graphics, and FTP programs. Firefox has great features that we'll be taking advantage of to help us streamline the design creation and theme development process. In addition to those built-in features such as the DOM Source Selection Viewer and adhering to CSS2 standards as specified by the W3C, Firefox also has a host of extremely useful extensions such as the Web Developer's Toolbar and Firebug, which I recommend to further enhance your workflow.
Get the extensions:
You can get the Web Developer's Toolbar from https://addons.mozilla.org/en-US/firefox/addon/60 and Firebug from https://addons.mozilla.org/en-US/firefox/addon/1843. Be sure to visit the developers' sites to learn more about each of these extensions.
Don't worry, we won't forget about all those other browsers! However, in addition to Firefox having all the helpful features and extensions, IE has a thing called quirks mode, which we will learn all about in Chapter 4. While Microsoft has attempted a lot of improvements and tried to become more W3C compliant with IE7 and now IE8, there are still some CSS rendering issues between these IE browsers and others.
Your best bet will be to design for Firefox first and then, if you notice that things don't look so great in IE6, IE7, or IE8, there are plenty of "standardized" fixes and workarounds for these three browsers because their "quirks" are just thatâwonks and well documented.
As we'll learn in Chapter 4, if you design looking at only one version of IE, then find it a mess in Firefox, Opera, or Safari, or the new Google Chrome you're going to have a much harder time fixing the CSS you made for IE in a more "standards-compliant" browser.
Firefox doesn't have to become your only browser. You can keep using IE or any other browser you prefer. I myself prefer Opera for light and speedy web surfing, but it doesn't handle all pages perfectly. As a designer on Mac who works with and for other creative Mac-based professionals, I regularly check my work in Safari. Firefox is one of my key web development tools.
To get going on your WordPress theme design, you'll want to understand how the WordPress blog system works, and have your head wrapped around the basics of the WordPress project you're ready to embark on. If you'll be working with a more technical WordPress administrator and/or PHP developer, make sure your development installation or sandbox will have the same WordPress plugins that the final site needs to have. You'll want to have all the recommended tools installed and ready to use, as well as brush up on those web skills, especially XHTML and CSS. Get ready to embark on designing a great theme for one of the most popular, open source blog systems available for the Web today!