minor bug in Blix wordpress theme : found & fixed
Last night I added the post list functionality to SEO Dave’s almost-spring-adsense theme by copying the functions from his Blix-adsense theme . When previewing the new post list on this site running Wordpres 2.1 on FC6, I noticed the very single post is listed in the ‘most recent posts’ list on the sidebar as well. That’s a bit unusual.
Recalling the current post is excluded by the BX_get_recent_posts(), I believe I found a bug in Blix-adsense theme. The same bug also manifested in Dave’s own site which uses Blix-adsense-seo-02. The function itself seems to be OK.
function BX_get_recent_posts($current_id, $limit) {
global $wpdb;
$posts = $wpdb->get_results(”SELECT ID, post_title FROM ” . $wpdb->posts . ” WHERE post_status=’publish’ ORDER BY post_date DESC LIMIT ” . $limit);
foreach ($posts as $post) {
$post_title = stripslashes($post->post_title);
$permalink = get_permalink($post->ID);
if ($post->ID != $current_id) echo “<li><a href=\”" . $permalink . “\”>” . $post_title . “</a></li>\n”;
}
}
I checked the actual call from sidebar.php. There, I found the bug. $p is passed as current post id to the call, but is not defined anywhere. Therefore, the excluding based on post->ID fails as intended.
<h2><em>Most Recent Posts</em></h2>
<ul class=”posts”>
<?php BX_get_recent_posts($p,10); ?>
</ul>
Since Dave’s work mainly is adding Google Adsense to the original Blix Wordpress theme, I assume the bug is from the original theme. Downloading from the author’s site (Sebastian Schmieg) or from wordpress.org’s theme site, give basically the same zip file, except for a minor difference in the footer.php
# diff Blix/footer.php blix/footer.php
8c8
< Icons by <a href=”http://www.graphicpush.com/blogicons/”>Kevin Potts</a> . Powered by <a href=”http://www.wordpress.org/”>WordPress</a> . <?php wp_loginout(); ?></p>
—
> <a href=”http://www.kingcosmonaut.de/blix/”>Blix Theme</a> by Sebastian Schmieg. Icons by <a href=”http://www.graphicpush.com/blogicons/”>Kevin Potts</a> . Powered by <a href=”http://www.wordpress.org/”>WordPress</a> . <?php wp_loginout(); ?></p>
Notably, the author’s blog site states the theme is for wordpress 1.5 and single-post view doesn’t have this symptoms. His site indeed runs wordpress 1.5, judging from the META as received & excerpted from his wordpress blog server.
<title>Blix Preview</title>
<meta http-equiv=”Content-Type” content=”UTF-8″ />
<meta name=”generator” content=”WordPress 1.5” />
So, I wonder if $p was actually defined as $post->ID for wordpress 1.5, thus not a problem there. For wordpress 2.0 and wordpress 2.1, it is not and became a minor bug.
The fix is actually pretty simple. We just need to define $p as ID for the current post in the single post view, before BX_get_recent_posts() is called. With the fix, now we see only nine posts listed instead of ten. The fix for the original Blix theme is like:
$ diff sidebar.php sidebar.php.new
82a83
> <?php $p = $post->ID; ?>
—
The fix for sidebar.php in blix-adsense-02 is like
$ diff sidebar.php sidebar.php.new
101a102
> <?php $p = $post->ID; ?>
—











Harry Conter said,
February 6, 2007 @ 9:29 am
Thanks for your informative post!
I’ve actually recently come across an updated version of the blix theme called Blix Krieg, which seems to fix all these probs, and adds greater functionality to the adsense code spoken about above.
It’s worth a look - http://www.utheguru.com
experts8 said,
February 7, 2007 @ 5:32 pm
harry,
thanks. It does look better. I’ll try it out. The site still has the current single post listed under ‘most recent posts’ though. kinda minor
experts8 said,
February 7, 2007 @ 5:55 pm
BTW, sorry for the delay in response. This wordpress server was configured to send an email to alert me for any comment. I was surprised I didn’t receive any alert for your comment, up to now.
Searching in spam or trash folder turned up nothing either. no offense, just meant to be thorough here.
From the mail log entry below, google’s SMTP server did accept an email from this server to my email account right after your comment. I guess this would be the first occurrence of lost email by Gmail for me.
Not exactly sure whether I should count the first lost email as a blessing only because it happened to other people quite a bit. This definitely violates RFC for SMTP. A MTA implementation should either take it or reject it. Once it takes it, it should ensure delivery. Not to mention the destination is Google’s own servers.
Feb 6 09:29:30 server1 postfix/smtp[18834]: 1D5F177A82: to=, relay=gmail-smtp-in.l.google.com[66.249.83.27]:25, delay=3.4, delays=0.28/0.15/0.62/2.4, dsn=2.0.0, status=sent (250 2.0.0 OK 1170772170 i35si17374027wxd)
TheDuck said,
February 10, 2007 @ 11:44 pm
Hi There!
As per your suggestions, I’ve added your code to the blixkrieg theme.. you can see my beta page at http://beta.utheguru.com
All the best,
TheDuck
experts8 said,
February 11, 2007 @ 10:19 am
great. I just checked out the beta site, there’s only one post, thus it is hard to verify whether the fix is in or not.
TheDuck said,
March 8, 2007 @ 6:03 am
Hiya!
I’ve added some more posts to the beta -
Now using that site as my own personal clearing house for changes I make to BlixKrieg prior to releases, and playing with things like section targetting in google.
Cheers,
TheDuck
experts8 said,
March 8, 2007 @ 11:30 am
Yes, Mr. TheDuck. The bug-fix does seem to be effective on your beta site.
how can i check my verizon email said,
October 31, 2007 @ 7:02 pm
how can i check my verizon email
how can i check my verizon email