A Primer for WordPress’ query_posts()

I’ve probably looked up code examples for query_posts() more than anything else in the whole Codex. I need to commit a basic example for myself, and in the hope that it will benefit others trying to do this basic, basic thing.

Here goes:

     $args = array(
                   'cat' => '44',
                   'post_type' => 'post',
                   'posts_per_page' => 15,
                   'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1),

	while (have_posts()) : the_post();
		get_template_part( 'content'); 

This basic query will go find the last 15 posts in category 11. Just as easy as that. There’s a bunch of other filters you can append to the query or add to the query array: cat=11&year=2009&tag=design to bring back all articles tagged with design in category 11 that were written in the days of yore (2009).

Paste this code into your template files (with surrounding PHP tags) for a quick way to show your posts on a page, on a footer or sidebar, or wherever else you want.

WordCamp St. John’s Now Live

An update from a few weeks ago — the site for WordCamp St. John’s is now up! If you’re interested in participating in any way (presenting, volunteering, organizing, etc) please leave a comment.

And don’t forget to tweet to your friends!

[browsershot url=”http://wordcampstjohns.ca/” width=”500px”]

Leave the em dash alone?

…if you want to make your point—directly, with clarity, and memorably—I have some advice you’d do well to consider. Leave the damn em dash alone.

I can’t disagree with Ms. Malone here, but I’m saddened that this will likely cause me some pause when I write—the em dash has long been a personal favourite mark.

The case for single-page websites

In the past few weeks, I’ve looked up dozens of local business websites. Almost all follow a similar pattern: including pages for a welcome message, company history, products/services on offer, often sub-pages for each individual product/service, a contact page, and sometimes a company blog.

While some of the homepages I visited look ok, most of the other pages don’t. The strange pattern they all followed was that they almost seemed to run out of gas after they’d come up with the homepage. In almost every case, sub-pages looked like this:

Of course we know that they didn’t run out of gas—they simply ran out of content. All of these sub-pages suffer the same enviable slim-around-the-middle fate, without enough content to expand the beltlines. There’s a better, easier and more effective way: Put it all on a single page.

The best story you’ve ever told, all on a single page

The page above is flat and lifeless. The sidebar continues on forever down the side, the footer just sits there discontentedly, and the actual content looks sad, naked and exposed. Designing for one page forces you to actually think about what you want to say, resulting in a tighter, firmer outward appearance for your clients.

Why do you need those pages anyway?

  1. Contact us—a single line in the header or footer would work just as well. List your phone number and email address, done and done.
  2. Company history—if you’re depending on your company’s history to draw in new business, you’re doing it wrong. Your company is successful and long-lasting because of your great service, committment to customers, and your positive attitute. These core messages belong front and centre on the frontpage, not hidden on a History page that no one will ever read.
  3. Products/Services—unless you’re selling products that I can look at and order online, you don’t need a page for each of them. An accountant, for example, doesn’t need individual pages for bookeeping, personal income tax, corporate income tax, consulting services, etc, etc, etc. You’re an accountant—just put these things in a list under services. If I’m already looking for an accountant’s services, I just need to know if you offer it or not.

The result of a one page site could look something like this:

Even without real content, you can see it looks much better already. It’s all the same stuff you wanted to say before, but now it’s thought out much better and will do a way better job of grabbing attention. The last step is counting the money as it rolls in. Have a look at a few examples to get you going.