P2hcom

DESIGN toXHTML

Figure 3.72. Psdtuts+ showcases several custom advertising spots in their site template

Lightboxes

A lightbox is essentially a JavaScript plugin that allows users to load large images inside a hovering container. This feature has grown steadily in popularity for photography and other image-dependent sites. When designing your theme, you should consider whether a lightbox would be appropriate for users. If you decide that it would be helpful, you're then faced with choosing what form it takes; this is where your script research from the last chapter will come in handy.

A standard example of a lightbox is shown in Figure 3.73. The prettyPhoto 3.0 plugin uses jQuery to present images in a gallery format. Note the thumbnail images along the bottom, as well as the arrow navigation.

Figure 3.73. The prettyPhoto 3.0 plugin

Social Media Add-ons

There is a wide variety of free plugins that allow users to include social media links in a WordPress site with little hassle. You can also bake these features directly into a theme, bypassing the need for a plugin altogether. Sidebar widgets and a list of social media buttons—for Twitter, Facebook, Digg, Delicious, and the like—at the bottom or top of a post are the most common ways of including such features, but you can also integrate them into the header or footer of your theme.

Figure 3.74 and Figure 3.75 are two examples of the kind of functionality you might consider; both are taken from the SitePoint blogs.

Figure 3.74. A sidebar social media widget

Share thii on Reddit

Figure 3.75. Social media sharing at the end of each post

Don't Leave Anything Out!

What you should take away from this chapter is the following: WordPress has a fixed number of parts for which you must design. In order to have a robust, usable theme, you need to account for all of these. Even if you have no plans to use each and every text element, form, or widget in your version of the theme, publishers using your theme might wish to—so to ignore designing for them will only prompt those publishers to go elsewhere because you fail to give them what they need.

Unlike a static website where you know exactly what elements you're designing for, it's important to account for everything in a WordPress theme. Make sure you look at all of the common HTML elements, WordPress widgets, and page templates when you're in the mockup stage.

Putting It All Together

Now that we've reviewed the core principles of design that affect a WordPress theme, as well as the basic elements that a theme is unable to live without, it's time for you to go to work on your own design. The next steps in the workflow of this book will walk you through actually building your theme, but I hope that you leave this chapter with a better impression of how WordPress themes are structured and designed. At their core, WordPress themes are a lot like any other website design. By following the fundamentals discussed in this chapter, you should be knocking out your own wicked themes in no time!

Chapter

Theme Frameworks by Raena Jackson Armitage

Once you have an idea of how you'd like your blog to appear, it's time to start hacking on the theme itself. Typically, a WordPress theme needs a number of core files to function—files for the index page, single posts, static pages, and all the bits and pieces that live inside, such as comments and sidebars. WordPress's core theme, Twenty Ten, contains 22 files in total, and that's excluding the images. There sure is a lot of work in there!

Savvy developers know that reinventing the wheel is for suckers, and when you want to start off on the right foot, it's often faster and easier to build on top of a framework. PHP developers have frameworks like CakePHP or CodeIgniter; Ruby geeks have Ruby on Rails; .NET developers have ASP.NET. The WordPress theme community is no exception—theme development frameworks have arisen to make it simpler for you to create your own theme.

WordPress theme development frameworks look just like regular themes—dare we say, even a little bit boring—yet underneath their modest facades lies powerful functionality that acts as a scaffold for your own theme development. In this chapter, we'll look at why frameworks are such a great idea, how to choose the best theme framework for you, and how to augment that framework with our own sexy styles and custom functionality.

Why use a framework?

I bet you're busy, right? You're probably also excited to start your theme development as soon as you can. And as your theme career grows, you'll appreciate anything that can help you save some time. Theme development frameworks are here to make your life a whole lot easier.

Frameworks provide markup, functional elements, and often some basic CSS, all of which you can use as a foundation for your own theme. For beginner themers, using a framework means that you can spend less time putting together your code, and more time concentrating on your design. It's also a great way to learn about how WordPress themes are put together, especially if you're fairly new to PHP.

Later on, once you've established yourself as a world-renowned WordPress theme rock star, you'll find that using a framework saves you time: you'll spend less time on doing the repetitive work that every theme requires, and more on the finer details of your newest masterpiece.

Child Themes: The Smart Way to Build on a Framework

Back in ye olden days, if you wanted to modify the output of a WordPress theme, you'd have to edit the theme directly. There were very few opportunities to alter a theme's markup or functionality without changing the template files. If the theme you started from was upgraded, you'd then have to spend time carefully integrating your alterations back into the newly updated original—hardly the most productive use of your time.

WordPress 2.7 changed all that when it introduced the concept of a child theme—a theme that extends on the capabilities of another theme. At a minimum, a child theme needs only a style sheet (style.css) within its own directory, and another theme specified as the parent. When WordPress builds a page, it'll take the style sheet from the child theme, and the templates from the parent theme.

But for the more adventurous, child themes can help you go even further, with two ways to override the behavior of the parent. There's an additional file, functions.php, that's available for adding your own code to the theme. What's more, template files stored within the child theme's directory will override those of the parent. This means that if you'd like to make changes to the parent theme's markup or functionality, all you need to do is write a custom function, or make your own version of the relevant template—and voilà, complete control.

Here's the best bit: while the WordPress community has developed a number of feature-rich frameworks especially for this purpose, any theme can act as a parent. If your favorite theme permits modification in its license, you're free to go right ahead and use it as a framework for your lovely new theme, without editing the original in any way.

There's nothing to prevent you from directly modifying a theme framework, if that's what floats your boat, but the smart money's on using a child theme as often as you can. Whenever your parent theme's developer makes an update to their theme, updating yours is as simple as installing the fresh version of the parent. Your child theme will be instantly updated at the same time, meaning that you spend less time worrying about incorporating your changes.

In this chapter, we'll be keeping a very important maxim in mind: hands off the parent theme! It's the cleanest, simplest way to build on a theme and avoid tripping over your own toes.

How do I choose a great framework?

As I mentioned earlier in this chapter, you can use any theme as a framework—providing, of course, that its license permits you to do so. That often means that a premium—or paid—theme is a poor choice for anyone who wants to distribute their themes for free. Here are some important points to examine.

Clean, semantic HTML

A theme with valid, semantic HTML means that it'll be a breeze to style up your theme with your own CSS. If your prospective theme has a demo page, run it through the W3C validator1 and see what falls out. You should also keep an eye out for plenty of class hooks for you to hang your CSS on, as this will make your job much easier when it comes time to create your child theme.

CSS examples

A good framework will ideally come with some minimal CSS you can use as a starter for your own styling. A great framework will have a number of layouts available for you to use; ideally, it will also have different stylistic concerns such as typography, color, and layout placed in separate files, making it simple for you to pick and choose from the defaults.

SEO benefits

If you've dreamed of seeing your theme on thousands of popular blogs, you can bet that SEO will be uppermost in those bloggers' minds; it should be right up there in yours, too. Your framework's markup should follow good SEO practices, such as a sensible use of headings and semantic elements, descriptive title elements, and good use of meta elements.

Widget-ready

Your framework should include plenty of places for WordPress widgets. Your users will be less than impressed if your theme only permits widgets in sidebars. Choosy bloggers look for themes that support widgets above and below posts, in headers and footers, and indeed anywhere they can squeeze in their favorite gadgets and goodies.

1 http://validator.w3.org/

Plays well with plugins

Your choice of framework should, ideally, play nicely with popular plugins. Some frameworks already include CSS for the most popular plugins, and at the very least, the framework developer should have tested the theme on a blog with plenty of plugins installed.

Documentation and support

A good theme framework will have documentation and an avenue for support, whether that's a forum, wiki, mailing list, or even a support ticket system. Take a look around and see what the community's like—are they helpful angels or cranky trolls? This is especially true if you're buying a paid theme; why drop all that cash for shabby or non-existent support?

Frameworks Worth Checking Out

Although any theme could conceivably be used as a framework, some notable examples have been designed especially for this purpose. We'll take a look at these now, as well as some child themes that have been created from them.

Freebies

Here are just a few of the great free frameworks on offer.

Thematic

Ian Stewart's Thematic, shown in Figure 4.1, is one of the best-known theme frameworks out there, and for good reason: it boasts thousands of users, it has been tested with dozens of popular plugins, and there's plenty of helpful, free community support. You can grab Thematic from ThemeShaper, which is also home to a huge collection of tutorials about building child themes, as well as creating your own framework.

Figure 4.1. A plain Thematic demo, using the default styles

2 http://www.themeshaper.com/

Thematic child themes are plentiful: Figure 4.2, Figure 4.3, andFigure 4.4 show just how flexible this framework can be.

ThemeShaper ®

Shaping WordPress Themes

!. About ii. Contact

Home Blog i Thematic

Home Blog i Thematic

To search, type and hit en ter

Figure 4.2. ThemeShaper uses a Thematic child theme

To search, type and hit en ter

Thematic, A WordPress Theme Framework

Thematic is a free, open-source, highly extensible, search-engine optimized WordPress Theme Framework featuring 13 widget-ready areas, grid-based layout samples, styling for popular plugins, and a whole community behind it. It's perfect for beginner bloggers and WordPress development professionals.

Figure 4.2. ThemeShaper uses a Thematic child theme

Blogging For Cash

Blogging For Cash

Simple secrets to turn your computer into a cash machine. Successful Bloggers know that with the right money making opportunities blogs can become cash generating machines. If you want to start a profitable blog, or profit from an existing blog, you need to know this information. Start blogging for cash today and learn everything you need to know to profit from your blog.

Get My Free Ebook


Post a comment