Home » Featured » Creating A WordPress Theme

Creating A WordPress Theme

If you’ve already got some design chops and a WordPress blog, but you find the idea of turning it into a WordPress template a bit daunting, you’re not alone. Creating your own WordPress theme is actually easier than you might imagine, and although some PHP-fu is certainly helpful, you don’t need to be a PHP rockstar to pull off an amazing template design.

Creating your own WordPress theme will allow you to break out of free (or commercial) templates that mean your blog invariably looks just like hundreds (if not thousands) of other blogs out there using the same theme. Plus, once you’ve created a few and feel pretty comfortable, you can potentially take on paid work customizing WordPress templates, create commercial templates to sell to people less brave than you, or offer free templates on your website as a way to draw traffic to your blog.

Getting Started

First things first, if you have something designed already, I strongly urge you to code it out into (X)HTML before even looking at a WordPress theme tutorial. Trying to wrangle style sheets while trying to grok the theme structure might be a bit much, so you’ll be ahead of the game if you’ve already got your design and (X)HTML coding done. (If you’re unsure about how to code a table-free layout, using only CSS, check out our article, Making the Leap to All-CSS Layout.)

One thing to keep in mind as you’re slicing and dicing your design and beginning your layout coding, there are some commonly used CSS element names in most WordPress themes that you may want to use in your code. Chance are, you’re not going to be creating every single template file from scratch, but rather, reusing a sample or tutorial template. Keeping the element names consistent will make this much easier in the long run. The template classes often used are:

  1. #wrapper (holds the entire layout except the footer)
  2. #header (header part, including top page navigation)
  3. #content (container that holds your main page content and sidebar)
  4. #left-col (for the posting area, comment section and respond section)
  5. #right-col (your sidebar)
  6. #footer (footer)

Quick Note on CSS

Notice that we’re using element ids instead of classes in the list above. This is because classes (such as li.foo or .foo) are meant to be reusable. CSS id elements (such as #foo) are only used once in a page, and since these primary elements are never re-used on the page, we use ids instead of classes. Using ids instead of classes will make inheritance much easier and will speed up your development time.

Just as a reminder to CSS-newbies, if you have an element defined with an id (as opposed to a class), its very easy to control large groups of child class elements. For example, something like this:

<div id="nav">
<ul>
<li>Nav Item 1</li>
<li>Nav Item 2</li>
<li>Nav Item 3</li>
</ul>
</div>

To apply a style to all of the list item elements inside of the div with the id of “nav”, you simply use this:

#nav li {
color: white;
}

This would turn all of the text in your list items elements white. You can further define specifics by combining ids and classes, like:

#nav li.widget {
color: green;
}

That will cause the text in all of your list items with the class of “widget” within the “nav” div to turn green. Easy, right? I bring this up here (and my apologizes to anyone reading this who already understands the relationship between id and class) is because your WordPress HTML/CSS will be much cleaner and easier to work with if you take this approach.

Moving On…

While I could spend the time writing my own tutorial from scratch here, a few other people have already written ones that kick the crap out of anything I could come up with, so I’ll leave the actual nuts and bolts to them. A few tutorials really stand out from the rest. Some of these tutorials are pretty complicated and involved, while others work with only the basics to avoid confusing the reader with too much information.

How to Create a WordPress Theme from Scratch, brought to you by NetTuts, does exactly this, taking a very simple approach that may be particularly helpful with people still perfecting their CSS-fu. At the end of the tutorial, you end up with a plain, but functional, place to start that includes all of the basic functionality your blog will need, without overloading it with design elements that might be confusing.

How to Create a WordPress Theme from Scratch, brought to you by ThemeTation, is an incredibly comprehensive tutorial that starts with actually designing, slicing and coding the PSD file. It might be a little much for someone who already knows how to slice and dice their PSDs into submission, but part 3a starts at actual implementation into WordPress. While this tutorial is a bit long, it gives you a start-to-finish walkthrough that may be very helpful to some.

So You Want to Create WordPress Themes, Huh?, brought to you by WPDesigner, is a bit of a middle ground of the first two tutorials listed. It’s very comprehensive, but it assumes that you’ve already got the layout slicing mostly covered, so the real focus is on WordPress theme structure and functionality.

There is even a three-part video screencast tutorial available on the CSS-Tricks website. Pack a lunch, as the complete series is over two hours long, but Chris does a great job addressing theme creation from start to finish. They also provide the demo theme created in the video as a download, so you can play along.

A Word on Widgets

Plugins are arguably the best part of WordPress. Chances are, if you want your blog to have some special feature or function, someone has already created a plugin that does it. Not all plugins are widget-ready, but the ones that are usually use the same CSS containers, so that they will fit seamessly into your page design. (Not all widgets do this, which can be a pain in the ass, but you should plan for the standard and fix the ones that don’t comply.

The standard WordPress sidebar widget CSS looks something like this:

<div id="sidebar">
<ul>
<li class="widget">
<h2>Widget Name</h2>
<ul>
<li>Widget content 1</li>
<li>Widget content 2</li>
<li>Widget content 2</li>
</ul>
</li>
</ul>
</div>

Because this is a semi-standard format, you might want to consider coding your HTML in this way, so you have a better chance of widgets fitting into your site’s style right out of the box. It won’t work every time, but it often does, and I wish I had realized that when I first got started.

Next Steps

As usual, I tend to recommend that you actually follow the steps in these tutorials, one by one as you go. I’m a hands-on learner, so nothing makes information stick in my brain better than actually getting into the muck of it.

Personally, when I learned to make WordPress themes, I started with the simplest tutorials listed above, and then opened the default theme that comes with WordPress, copied it, installed my new copy under a new name, and used that as the place to start. Once I felt pretty confident there, I poked around in some of the more complicated themes, to see how they did what they do. Start simple – don’t try to conquer the world of WordPress your first time. The more comfortable you get with the structure and functions, the more great ideas you’ll have on what you can do with your blog.

When you’re ready to get more advanced, check out the WordPress Codex, that explains what each function within WordPress does, usually with detailed examples and documentation. If you start to get fancy with your WordPress queries, specifically with regard to specifying posts from only one (or more) categories, or all posts from one (or more) categories except the one you specify, the Template Tags – Query page in the codex will be your new best friend. The forums are also a great place to get answers to a specific question.

Advertisement

Themeforest

Advertisement

Net Tuts

flattr this!

About Alison Gianotto (snipe)

I’m a tech geek/dev/infosec-nerd/scuba diver/blacksmith/sword-fighter/crime fighter/ENTP/warcrafter/activist, and the CTO at Mass Mosaic in New York City. Tweet at me @snipeyhead or read more...
  • http://twitter.com/students/statuses/1106352658 students (Creative Resource)

    Creating a WordPress Theme – http://tinyurl.com/7nn37h by @snipeyhead

  • http://www.phpcult.com/ Vid Luther

    great stuff once again. you have a flair for writing articles that people want to read, and more importantly can follow. Thanks.

    Vid Luther’s last blog post..Scaling a startup, technically and fiscally

    • http://www.snipe.net snipe

      Thanks for the kind words, Vid :) I usually try to write these types of things shortly after I’ve done them, so I have a frame of reference. Really, I just write them to keep track of important facts and links for myself, since I have the memory of a sea cucumber. :D

  • www.phpcult.com Vid Luther

    great stuff once again. you have a flair for writing articles that people want to read, and more importantly can follow. Thanks.

    Vid Luther’s last blog post..Scaling a startup, technically and fiscally

    • http://www.snipe.net snipe

      Thanks for the kind words, Vid :) I usually try to write these types of things shortly after I’ve done them, so I have a frame of reference. Really, I just write them to keep track of important facts and links for myself, since I have the memory of a sea cucumber. :D

  • http://www.brandonsavage.net/ Brandon Savage

    Thanks a lot! You’re fantastic.

    Brandon Savage’s last blog post..Seven Things

  • http://www.brandonsavage.net Brandon Savage

    Thanks a lot! You’re fantastic.

    Brandon Savage’s last blog post..Seven Things

  • http://newwpthemes.net/ Susan

    This is quite helpful, to anyone! Thanks.

    Susan’s last blog post..Nature Gift

  • http://newwpthemes.net Susan

    This is quite helpful, to anyone! Thanks.

    Susan’s last blog post..Nature Gift

  • http://www.blog.mookiedesign.com/ Cam

    Pretty fresh, even though i know how to do my own themes, everytime i read another tutorial i learn something different. In this case the widget/plugin stuff.

    Cam’s last blog post..ThemeForest Designs

  • http://www.blog.mookiedesign.com Cam

    Pretty fresh, even though i know how to do my own themes, everytime i read another tutorial i learn something different. In this case the widget/plugin stuff.

    Cam’s last blog post..ThemeForest Designs

  • http://www.siteflipremix.com/ Wynter Jones

    Great review on wordpress creation, digging the links to other more advance posts too. You’ve also shown how easy CSS is and that is key in making great wordpress themes.

    Wynter Jones’s last blog post..What’s Hot on Site Flipping Marketplace

  • http://www.siteflipremix.com Wynter Jones

    Great review on wordpress creation, digging the links to other more advance posts too. You’ve also shown how easy CSS is and that is key in making great wordpress themes.

    Wynter Jones’s last blog post..What’s Hot on Site Flipping Marketplace

  • http://www.jo3y.com/ Joey

    Haha snipe, that’s exactly what I’m doing with my site. For years I saved helpful, clever, or otherwise awesome pages to places like magnolia and del.icio.us, (and Firefox)and then my friend Lee said I should offer them online somewhere with a good rundown of the page/feature/utility/whatever. So here goes nothin’!

    Awesome site by the way; design/features/writing/humor.. I hope I can do the same!

    –Joey

  • http://www.jo3y.com Joey

    Haha snipe, that’s exactly what I’m doing with my site. For years I saved helpful, clever, or otherwise awesome pages to places like magnolia and del.icio.us, (and Firefox)and then my friend Lee said I should offer them online somewhere with a good rundown of the page/feature/utility/whatever. So here goes nothin’!

    Awesome site by the way; design/features/writing/humor.. I hope I can do the same!

    –Joey

  • Pingback: وورد برس عربيا » Blog Archive » 25 درس لتعليم تصميم قوالب وورد برس الاحترافية

  • Pingback: 60+ Awesome WordPress Tutorials | The Best WP Themes Online