Justin Tadlock

Theme options and widgets for the Structure theme

Letting users more easily control their WordPress theme

If any of you’ve wondered where I’ve been the last couple of days, then I must tell you that I’ve been hard at work creating more options for the Structure WordPress theme. I didn’t plan on releasing an update this soon, but things were running too smoothly for me not to give something extra back to the users.

Before I give you the details, I want to ask you to please keep all theme support questions on the theme’s download page.

When I designed the theme, I intentionally placed everything on a three-column grid, so that users could easily move page elements around. I’m calling these elements “content blocks.” My plan was to eventually widgetize much more of the theme, while still offering the theme’s content blocks as individual widgets. I also wanted to add a theme options page because customizing the theme can get a little tedious for newbies and more advanced users.

Somehow, I learned to create theme-specific widgets and a theme options page in two days. I didn’t expect it to be this easy. In the back of my mind, I’m telling myself, “I must’ve screwed something up.” I’m fairly certain everything works properly though.

Theme options:

This was actually the easy part. There’s not a lot of tutorials or references on the Web about how to do this, but I found a good article on The Undersigned that helped. His example didn’t quite work right, and it took a bit of customization to fix.

Now, you can control your theme layout style from a page called “Structure Options,” whether you want to display the category tabs and their posts, and what specific categories you want in the tabbed categories section on the home page.

Creating the theme options page was so easy that I might release some other layout styles and color variations in future updates. There is minimal coding involved, so it wouldn’t be hard to do.

Widgets:

Automattic’s article on widgetizing themes was a bit lacking, which made this the hardest part to do. Turning some of my content blocks (video, recent) into widgets didn’t work well with the widget system at first.

The “home.php” file with its two content block sections below the category tabs and “sidebar.php” are now widget-ready in a very cool way. You can mix and match different sections of the sidebar or left and right home columns with theme-specific content blocks.

The great thing about this is that widget users now have full access to what non-widget users have — custom widgets for the Structure theme.

Thoughts:

With this system in place, I feel like I’m catering to a much larger WordPress crowd. Before, with all the customization it took to get things just right, I was shutting a door to a large portion of the WordPress community, even if I try to write complete “readme.txt” files.

The “readme.txt” file is now almost 14kb with around 2,000 words. It’s very informative, but still lacking a lot of information. I thought it’d be a little easier to give users a control panel (theme options and widgets) to work with than make them read any more than they have to.

I hope this satisfies current theme users and brings in new ones. It should be a good foundation to continue working from.

Tomorrow, I should return to my regular blogging schedule, but before I do, here’s a couple of questions for you. What kind of theme options would you like to see in Structure and future WordPress themes? Do you have any other ideas to add?