A journal about WordPress, the web and design.

About have_posts()

About the author

Jack has been building websites since he was 11 and started learning, and using, PHP and MySQL in 2004. A few years later he discovered WordPress and his mind was literally blown open.** Since then he has been on a voyage of discovery trying to prove that you can, and should, build absolutely any website using WordPress (except sometimes when you shouldn’t.)

When it comes to the web, Jack loves a bit of everything and enjoys occupying the grey area between being a front end and a back end developer, i.e. he doesn’t really know much about either. Latterly he has developed an obsession with preprocessor languages including Sass/Compass, CoffeeScript and Haml. If you want to join the party, he highly recommends you get acquainted with CodeKit.

When Jack isn’t writing self-deprecating biographies of himself in the third person, he enjoys writing, reading, walking, skiing, climbing, gallivanting (and hopefully soon speed flying) in the Lake District, where he lives.

Oh yeah, and he loves F1.

*cf. Garth Marenghi (I fear people taking that literally.)
** and I do mean literally – it was a mess.

About the journal (and it is a journal)

In the pursuit of trying to build almost everything using WordPress, Jack often finds himself Googling for some guidance to solving a certain problem. Less frequently, Jack is unable to find any guidance, or at least is unable to find help with exactly what it is he’s trying to do. Therefore over the years he has created many a solution to a problem that continues to be unresolved in the realm of internet forums/blogs etc (or it has been solved but is difficult to find after many different Google searches.)

After several abortive attempts at getting a blog going, Jack has decided to start sharing ideas and solutions via this new journal. He may use it to discuss other things from time to time, and he may use it to share snippets of code that don’t necessarily directly relate to WordPress, but at the very least he intends to post at least vaguely helpful things every now and again.

Canny readers will understand the title of this website and have a little chuckle to themselves at its wondrous ingenuity. For those not in the know, have_posts() is a key pillar of “The Loop” in WordPress. A full expression of The Loop being:

The Loop

PHP

1

2

3

4

5

6

7

8

9

<?php

if(have_posts()){

while(have_posts()){

the_post();

?>

// Content goes here

<?php

}

}

N.B. After a reprimand on Twitter, I have updated the above loop and relented to the wisdom of @Tarendai. See his criticism of my previous expression of the loop here. I do have some arguments for my previous version, but the above one is better practice!