Code is Poetry

March 2, 2008

And it can also be frustrating. I have been coding up a website for a friend and I was testing the blog component for scale. I have allowed for a user-defined maximum of posts visible on a page. I have code that allows a user to scroll through prior posts.

I started the test case thinking that it would take just a few minutes. I added about 40 posts to ensure that the scrolling would work. However, I kept getting the same ten posts over and over. The previous and next links would show as expected but the posts would not change.

I spent almost ten hours debugging this particular function. The solution, buried deeply in one of the WordPress forums, was obvious:

<?php {$paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;  query_posts(“cat=1&paged=$paged”); } ?>

Code is poetry. It works now. I can take some time off to celebrate my birthday.

Trevor Dick March 2, 2008 at 6:26 pm

Happy Birthday, Richard!
If I was there, I would do a rendition of your choice on my violin.

Trevor

Reply

Richard Cleaver March 2, 2008 at 7:59 pm

Thanks Trevor!

Reply

Rob March 4, 2008 at 12:27 pm

While a bit late, Happy Birthday, Richard! Hope you had an enjoyable day/evening! Rob

Reply

Leave a Comment

Previous post:

Next post: