Paying more attention to my blog this Semester (obviously) I noticed there was a very simple, but annoying error when viewing a single post: the headline, content and comments were all listed twice on the one page.
As it’s been five (5) years since I last looked at the code, which even then was a “cut, paste and hope” effort – code from WordPress placed on the site – I couldn’t even remember whether this error had crept in somehow or had been there since launch. So fixing it was going to be no easy task.
The proposed solution: trial and error. I went through different sections of the PHP statements, cutting out different chunks each time and testing to see if I could isolate the code that was causing the problem. This was actually inconclusive – after a dozen combinations, hiding bits and pieces, I was still getting the duplicate.
So as a different method, I compared to a different section, the home page, which includes the post with less details. It was here I found the following …
BEFORE the content:
<? php static $ctr = 0; ? >
AFTER the content:
< ? php $ctr++; } ? >
Funnily enough, I still don’t know what the syntax means for these statements, but happily I don’t need to: I know that they’ve fixed the problem. The moral of the story being – it’s about the result, however you manage to get there!