Review is a key part of Theme Wrangling, so we spend a lot of time looking “under the hood” at themes. Here are some of most common theme development errors that come up in the review process, and some tips on how to avoid them.
Category Archives: Theme Tips
The Recipe for a Great Theme
Have you ever looked at a WordPress theme and thought, “Man, I wish I could do that!” Well, here’s a little secret: You totally can.
Yes, you can make a theme, and you don’t need to be a theme expert to do so. You just need three things:
- An idea,
- a healthy dose of curiosity,
- and time.
An Idea
Until five years ago, I’d never touched a WordPress theme. I didn’t have a lot of experience, I’d never experimented with dynamic programming languages, and I’d never had to design for a vast and varied audience.
But what I did have were ideas – how about a theme for babies? Or a theme with changing seasons? Or a theme with animated fish? I didn’t know how to make these themes happen – I just knew I wanted to make them.
Without an idea, there is no theme! So before you do anything, figure out what you want to build. Have a goal to strive for, write up some notes, sketch it out.
It doesn’t have to be mind-blowing, or revolutionary, or the Next Big Thing, as long as you’re excited about it. You’re probably not going to make history with your first theme, but why let that deter you from making something really cool?
A Healthy Dose of Curiosity
If you like to learn, you’ve already taken a huge step toward becoming a themer. WordPress changes often, so theming techniques change often, too. You don’t have to venture far for learning material – you’re looking at a wealth of theme-makin’ goodness right here at ThemeShaper!
But I encourage you not to get mired in the technical details. You know how you may use Photoshop, but you probably don’t use one-tenth of its capabilities? Theming is like that. You don’t need to know how to do it all – you just need to figure out one piece at a time.
Think of your theme as a puzzle, and break it into smaller components – a fixed sidebar, an animated drop-down menu, a customizable header that changes colors – together they’re an intimidating obstacle, but if you tackle each piece individually, you’re likely to find it’s not as difficult as you think.
Also keep in mind, you don’t necessarily need to start from scratch (unless you want to!) Maybe you’re less interested in coding a theme, but you want to illustrate one – you can always build a child theme, or use a starter theme, so you don’t have to dive as deeply into the code.
Here are some of our favorite ThemeShaper resources to get you started:
- The ThemeShaper WordPress Theme Tutorial: 2nd Edition
- Introducing The _s Theme
- WordPress Child Theme Basics
And finally, tutorials have their place, but don’t be afraid to play around! Some of the best learning experiences and discoveries are hands on. Remember: There are very few things you could do to your WordPress theme that a quick Ctrl+Z can’t fix.
Time
We’ve come to the part I can’t help with. You have the idea, you have the tools, now you just have to make it happen. Easier said than done, but as they say, Rome wasn’t built in a day. Some of the best themes take weeks, months, or possibly even years, to come to fruition.
But beware: Theming is addictive. If you spend enough time with it, you may find yourself staying up late into the night to squash a CSS float bug, or research scripts for a post slider, or find just the right shade of blue for that navigation menu. Don’t say I didn’t warn you!
I hope this inspires you to give theming a chance if you haven’t already – it’s a great opportunity to try something new and make something cool!
Finding the Perfect Theme
Optional Markup for Optional Post Titles
Whenever I write a post to publish on a WordPress powered website, I start by crafting a title. While I do this 99.9% of the time, there are definitely situations where no title is needed for a post.
Incorporating the Settings API in WordPress Themes
WordPress Theme Reviewer Chip Bennett explains how to incorporate the Settings API in your WordPress themes and build a robust and secure tabbed theme options page.
Post Formats and Content Templates in the Toolbox Theme
Toolbox 1.1 is on it’s way with support for two of WordPress 3.1′s new Post Formats — Aside and Gallery — and a new template structure based on a content.php template. Let’s take a look at what’s new.
Update: It’s available now! Go get it and check it out.
So, Post Formats. I love them and I bet if you’re at all interested in WordPress theming you’re probably interested in them too. Toolbox 1.1 will add support for Aside and Gallery posts along the same lines as the new Twenty Ten theme will. If you’re familiar with the Twenty Ten theme you know what to expect. It already mimics this new feature with Categories. Asides have a hidden title on blog pages and Gallery posts have a thumbnail from your post’s gallery along with a sentence letting visitors know how many images are in the gallery. It’s pretty cool.
Custom Menu Code Samples
Do you find yourself taking older themes and adding support for Custom Menus? Here are code samples that you can use for just that.
To be clear, this isn’t a full-blown tutorial for Custom Menus. See Justin Tadlock’s excellent post, Goodbye, headaches. Hello, menus! or the wp_nav_menu Codex page for all the juicy details.
The Perfect Blog Theme
What is the perfect blog theme? I’ve been thinking about it and I think I have the answer.
For the blogger: The perfect blog theme disappears into the background and doesn’t hinder their writing in any way—in fact, it encourages it.
For the reader: The perfect blog theme disappears into the background and doesn’t hinder their reading in any way—in fact, it encourages it.
Please note what I haven’t included in my answer. It’s important.
Know of any publicly released themes that fit my criteria? I’d really like to know about them. Let me know if you’ve found them, or just let me know your thoughts on the perfect blog theme by leaving a comment.
And don’t be afraid to argue! I’ve been known to be wrong!
Registering New Sidebars for Custom Page Templates The Smart Way
One of the cooler ideas for a new WordPress default Theme that’s come up has been the idea of including a not-so-blog-ish custom home page template with the Theme. Something optional that you could use if wanted your home page to look a little different. Maybe more of a traditional web site look (whatever that is) or a magazine look. Simply create a new page, assign this custom template to it, set it as your home page, and boom! New look.
I thought this was a great idea too. Especially if that custom page template was totally widgetized. Load up whatever dynamic content you want there with the Query Posts Widget or just use Text Widgets. The default styles of the new 2010 Theme can decide which of several widget areas is the ‘featured’ area and if you want something different—without wanting to change the markup—you can move things around with a Child Theme.
Great, right? Wrong.
You’d have to register new widget areas. Widget areas that would be confusingly unavailable if you weren’t using the custom home page template. Unless …
Here’s a really nifty function written up by Chris Gossmann that’ll check to see if a particular custom page template is active. Chris had to write a SQL query to get this to work so be thankful that he survived to tell us about it.
function is_pagetemplate_active($pagetemplate = '') {
global $wpdb;
$sql = "select meta_key from $wpdb->postmeta where meta_key like '_wp_page_template' and meta_value like '" . $pagetemplate . "'";
$result = $wpdb->query($sql);
if ($result) {
return TRUE;
} else {
return FALSE;
}
} // is_pagetemplate_active()
OK. Even by itself that function is kinda cool. There’s a few neat things you can do with it. Here’s one. Combine it with the following code for registering a new sidebar in the functions.php file of your WordPress Theme:
function test_template_widgets_init() {
if(is_pagetemplate_active('template-active.php')) {
register_sidebar( array (
'name' => 'Test Widget Area',
'id' => 'test-widget-area',
'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
'after_widget' => "</li>",
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
} // end test for active template
} // test_template_widgets_init()
add_action ( 'init' , 'test_template_widgets_init' );
Can you guess what that does? Using our new conditional function, is_pagetemplate_active(), we’re registering a new widget area only if, in this case, template-active.php is being used by one of our pages. Completely bypassing our earlier problem of widget areas potentially hanging around without a page for them to be displayed on.
What do you think? Pretty cool, huh? I see lots of really neat possibilities here for custom page templates in WordPress Themes and in Child Themes.
40+ Thematic Resources, Tutorials and Links
The post Build WordPress Sites Fast With the Thematic Theme Framework by Es Developed is a great resource for anyone wanting to get started with the Thematic Theme. It lists over 40 resources and tutorials that’ll get you where you want to be with rapid WordPress Theme development.
And there’s some great explanation behind why you’d want to use the Thematic Theme. Under the heading Don’t Touch That Theme:
To create your theme, you don’t actually edit any of Thematic’s theme files. Instead, you make changes using a separate child theme.
It’s really powerful since you’re not actually touching any part of Thematic. You just get a nice starting place, without worries about future Thematic updates overwriting your code edits.
You don’t have to rewrite a bunch of code all over again–you’re just adding the bits that you want to be different. This works very much like the custom styles on WordPress.com hosted blogs.
Make sure you check out Build WordPress Sites Fast With the Thematic Theme Framework.
