10 Things You Must Know About WordPress Themes

Looking back at the code of my first attempt at a WordPress theme, I can easily see that without a proper understanding of WordPress theme template files and template tags, it can be a frustrating project to undertake. And although I am a HUGE fan of learning as you go, I wanted to share a few secrets that might save you a headache or two along the way.

1. The Loop
If you’re not familiar with “the loop”, you have no business trying to work with WordPress themes yet. The structure of the loop is simple, yet it’s vital to the development process. It goes a little something like this:



It is in essence a call to custom WordPress functions that query the database to see if you have posts. If you do (and while you do … it’s a PHP thing … a loop), then you can insert custom template tags inside the loop to display the content of the post. I won’t go into detail, but suffice it to say that this is something you need to understand. For more on the loop, go to the WordPress codex.

2. Pages
WordPress did us all a huge favor when they implemented the ability to have static pages (as opposed to blog posts) for static content. For instance, an “About Me” page or a “Contact” page. Pages can be a powerful tool at your disposal. You need to know how to display pages, how to call pages, how to style pages, etc. Pages can also be a powerful tool in using WordPress as a website content management system.

3. Sub-Pages
Also very important. WordPress allows you to set up pages in a hierarchical structure. It lets you choose (if you so desire) a page to be the “parent” or “child” of another page. This is important, especially if using WordPress as a content management system. It can also be helpful in simply organizing your pages, or displaying lists of pages. Which leads me to…

4. List Pages
If you’re going to be releasing free themes, or just developing one for yourself or a client, you are going to need to know how to list links to your “pages”. Whether it’s a simple list of all your pages, or a custom list of only specific pages, you need to know how to output a list in any way you can think of. Say for instance that you wanted to list all the “child” pages of a particular “parent” page somewhere. How would you do it? Or how do you remedy the “nested list” problem in a horizontal navigation bar? These are questions you should be able to answer immediately.

5. Template Tags
This is more generic, but you need to be very familiar with how to display content of any type in a WordPress theme. Learn to love this page. It’s gonna save your butt quite a few times. Most important (in my opinion) would be the section titled “Post Tags”. You’ll definitely want to spend some time in that section.

6. Query Posts
I’ve written some pretty neat tutorials on this loop qualifier over at the Blog Herald, and for good reason. This is a powerful tool, and if you want to be a serious WordPress developer, you need to know it well. It can be too powerful sometimes, so be careful. Definitely know what you’re doing before you start using this to call specific data. It will affect the other loops that follow it (if using multiple loops). Nevertheless, if you use WordPress as a CMS, you can beat query_posts.

7. CSS
CSS and web design are becoming synonymous nowadays. And a WordPress theme is no exception. Know what HTML you are outputting by observing the div structure in your template files. Then, style accordingly in the style.css file. Hacks, browser limitations, workarounds, etc. must all be in your arsenal. Making a good WordPress theme is 75% CSS because people like pretty stuff. They could care less how you manipulated the loop, they just want to make sure it looks good.

8. PHP
Duh, right? WordPress is built on PHP. But it’s more than that. Eventually you will run into a problem that you can’t solve using the built in functions of WordPress or a plugin. When this happens, knowing PHP can do you a world of good. I’ve written custom scripts for clients that do things from call random images, to displaying custom content. And it would be beneficial to at least know a little PHP if you want to develop WordPress themes.

9. Comments are not secondary
If you expect people to use your themes, you must also expect them to want a successful blog. Like it or not, people use their comments to measure success, and if a blogger wants commenters to comment, the comments have to look nice. That’s where you come in. It really doesn’t matter WHAT the look like, as long as they flow with the look of the theme, and each comment is separate from the last and next. You’ll have to use your creative skill here, and understand how a good comments.php file looks. Like I said, this is not a secondary issue.

10. Widgetization
It’s no longer optional. Anything you can widgetize, you must. Users expect it, and for good reason. What better way to display data than by drag and drop? I’m a WordPress designer and even I have used widgets in the past. It just doesn’t make sense not to your sidebars and bottom bars. It’s also a good idea make sure you have sufficient style in your CSS to cover the widget content.

11. BONUS TIP – Conditional Tags
One thing I’ve noticed is that instead using multiple template tags for different content, you can use a conditional tag to check what type of page is being displayed. For instance, instead of a search.php file, you can just use the is_search() conditional tag to output search page listings. Also, the is_home() function can be used a for all kinds of things. It only outputs data if you’re on the homepage. And the possibilities are endless with conditional tags. I literally use them ALL the time. Probably one of the best ideas the WordPress guys ever had. Still waiting on that is_subpage() function though 🙂

Keep in mind that this is MY list. If you have something to add, please do so in the comments below. I’m always looking for new tips and cool tricks to add to my stockpile 🙂

8 thoughts on “10 Things You Must Know About WordPress Themes

  1. Your first topic (1. The Loop) ends with, “It goes a little something like this:”. All I see is a space about five or six of your lines high, followed by the second paragraph, “It is in essence …” Is this correct?

  2. Nice list, especially the point about widgets being mandatory, these days. That had never occurred to me, but now that you’ve pointed it out, I can definitely see it.

    Also, great and informative site you have here. I’ll be returning often 🙂

  3. I really enjoyed your post because recently I started the work on my first WordPress theme and I found the answer to some questions.

    Thanks

Comments are closed.