So. I just spent about an hour, all told, trying to get something *very simple* to work right.
All I wanted to be able to do is exclude a particular category (specifically, my linkblog posts) from the lists of posts in my Wordpress theme. In it self, that’s a trivial task, just a matter of adding a conditional PHP tag in the “Wordpress Loop.” Okay, no big deal. But if I do that, then the number of posts displayed on each “page” is wrong — it is short by however many linkblog posts I have.
And that causes a problem. See there are several instances where I post a lot of links — or at least more than 5, which is how many posts per page I’ve told wordpress to display.
The fix for this is to use the query_posts() function available in Wordpress, which is still simple to do:
<?php
if (is_home()) {
query_posts($query_string.”&cat=-193″);
}
?>
should do exactly what I want if I put it before the “loop,” because it will affect the actual MySQL query that pulls the posts, rather than exclude the posts after I have them.
Yet for some reason, when I did that, I my posts in completely the wrong order.
a simple tweak should have fixed that:
<?php
if (is_home()) {
query_posts($query_string.”&orderby=date&order=DESC&cat=-193″);
}
?>
… but it didn’t. So I spent most of an hour trying many different ways to tell Wordpress/PHP the same thing. But nothing worked.
After extensive searching and the Web, I discovered that it turns out that this is a known issue — not with Wordpress, but with basically one specific version of MySQL.
Wanna guess which version of MySQL is included in the version of XAMPP that I’m using? Yep, 5.0.51a. The one that is broke.
Fortunately, GoDaddy has their server set up with an older version of MySQL (5.0.18), which does not seem to be affected, and the code I tried originally works just fine (though I did leave in the sorting bits, just to be sure).
I can live with that. It’ll mean that my development environment will be a little tweaked in terms of which posts I see when, but that’s okay.
Of course, if GoDaddy ever updates, I’m screwed. ![]()
