Posts

Code is Poetry

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.